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
Sébastien Peillet
otb
Commits
c343b68b
Commit
c343b68b
authored
6 years ago
by
Antoine Regimbeau
Browse files
Options
Downloads
Patches
Plain Diff
REFAC: indent code correctly
parent
a82af997
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx
+188
-189
188 additions, 189 deletions
Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx
with
188 additions
and
189 deletions
Modules/Wrappers/QGIS/src/otbQgisDescriptor.cxx
+
188
−
189
View file @
c343b68b
...
@@ -35,8 +35,8 @@ int main(int argc, char* argv[])
...
@@ -35,8 +35,8 @@ int main(int argc, char* argv[])
{
{
if
(
argc
<
3
)
if
(
argc
<
3
)
{
{
std
::
cerr
<<
"Usage : "
<<
argv
[
0
]
<<
" name OTB_APPLICATION_PATH [out_dir]"
<<
std
::
endl
;
std
::
cerr
<<
"Usage : "
<<
argv
[
0
]
<<
" name OTB_APPLICATION_PATH [out_dir]"
<<
std
::
endl
;
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
using
namespace
otb
::
Wrapper
;
using
namespace
otb
::
Wrapper
;
...
@@ -95,8 +95,8 @@ int main(int argc, char* argv[])
...
@@ -95,8 +95,8 @@ int main(int argc, char* argv[])
std
::
string
algs_txt
=
"algs.txt"
;
std
::
string
algs_txt
=
"algs.txt"
;
if
(
argc
>
3
)
if
(
argc
>
3
)
{
{
output_file
=
std
::
string
(
argv
[
3
])
+
module
+
".txt"
;
output_file
=
std
::
string
(
argv
[
3
])
+
module
+
".txt"
;
algs_txt
=
std
::
string
(
argv
[
3
])
+
"algs.txt"
;
algs_txt
=
std
::
string
(
argv
[
3
])
+
"algs.txt"
;
}
}
std
::
ofstream
dFile
;
std
::
ofstream
dFile
;
dFile
.
open
(
output_file
,
std
::
ios
::
out
);
dFile
.
open
(
output_file
,
std
::
ios
::
out
);
...
@@ -107,16 +107,16 @@ int main(int argc, char* argv[])
...
@@ -107,16 +107,16 @@ int main(int argc, char* argv[])
{
{
for
(
unsigned
int
i
=
0
;
i
<
nbOfParam
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
nbOfParam
;
i
++
)
{
{
Parameter
::
Pointer
param
=
appli
->
GetParameterByKey
(
appKeyList
[
i
]);
Parameter
::
Pointer
param
=
appli
->
GetParameterByKey
(
appKeyList
[
i
]);
if
(
param
->
GetMandatory
())
if
(
param
->
GetMandatory
())
{
{
ParameterType
type
=
appli
->
GetParameterType
(
appKeyList
[
i
]);
ParameterType
type
=
appli
->
GetParameterType
(
appKeyList
[
i
]);
if
(
type
==
ParameterType_OutputImage
)
if
(
type
==
ParameterType_OutputImage
)
{
{
output_parameter_name
=
appKeyList
[
i
];
output_parameter_name
=
appKeyList
[
i
];
hasRasterOutput
=
true
;
hasRasterOutput
=
true
;
}
}
}
}
}
}
}
}
...
@@ -131,32 +131,31 @@ int main(int argc, char* argv[])
...
@@ -131,32 +131,31 @@ int main(int argc, char* argv[])
for
(
unsigned
int
i
=
0
;
i
<
nbOfParam
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
nbOfParam
;
i
++
)
{
{
const
std
::
string
name
=
appKeyList
[
i
];
const
std
::
string
name
=
appKeyList
[
i
];
Parameter
::
Pointer
param
=
appli
->
GetParameterByKey
(
name
);
Parameter
::
Pointer
param
=
appli
->
GetParameterByKey
(
name
);
ParameterType
type
=
appli
->
GetParameterType
(
name
);
ParameterType
type
=
appli
->
GetParameterType
(
name
);
const
std
::
string
description
=
param
->
GetName
();
const
std
::
string
description
=
param
->
GetName
();
if
(
type
==
ParameterType_Group
||
if
(
type
==
ParameterType_Group
||
type
==
ParameterType_OutputProcessXML
||
type
==
ParameterType_OutputProcessXML
||
type
==
ParameterType_InputProcessXML
||
type
==
ParameterType_InputProcessXML
||
type
==
ParameterType_RAM
||
type
==
ParameterType_RAM
||
param
->
GetRole
()
==
Role_Output
param
->
GetRole
()
==
Role_Output
)
)
{
{
// group parameter cannot have any value.
// group parameter cannot have any value.
// outxml and inxml parameters are not relevant for QGIS and is considered a bit noisy
// outxml and inxml parameters are not relevant for QGIS and is considered a bit noisy
// ram is added by qgis-otb processing provider plugin as an advanced parameter for all apps
// ram is added by qgis-otb processing provider plugin as an advanced parameter for all apps
// parameter role cannot be of type Role_Output
// parameter role cannot be of type Role_Output
continue
;
continue
;
}
}
auto
it
=
parameterTypeToString
.
find
(
type
);
auto
it
=
parameterTypeToString
.
find
(
type
);
assert
(
it
!=
parameterTypeToString
.
end
()
);
assert
(
it
!=
parameterTypeToString
.
end
()
);
if
(
it
==
parameterTypeToString
.
end
()
)
if
(
it
==
parameterTypeToString
.
end
()
)
{
{
std
::
cerr
<<
"No mapping found for parameter '"
<<
name
<<
"' type="
<<
type
<<
std
::
endl
;
std
::
cerr
<<
"No mapping found for parameter '"
<<
name
<<
"' type="
<<
type
<<
std
::
endl
;
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
std
::
string
qgis_type
=
it
->
second
;
std
::
string
qgis_type
=
it
->
second
;
#if 0
#if 0
if (type == ParameterType_ListView)
if (type == ParameterType_ListView)
{
{
...
@@ -176,164 +175,164 @@ int main(int argc, char* argv[])
...
@@ -176,164 +175,164 @@ int main(int argc, char* argv[])
}
}
#endif
#endif
bool
isDestination
=
false
;
bool
isDestination
=
false
;
bool
isEpsgCode
=
false
;
bool
isEpsgCode
=
false
;
// use QgsProcessingParameterCrs if required.
// use QgsProcessingParameterCrs if required.
// TODO: do a regex on name to match ==epsg || *\.epsg.\*
// TODO: do a regex on name to match ==epsg || *\.epsg.\*
if
(
name
==
"epsg"
if
(
name
==
"epsg"
||
name
==
"map.epsg.code"
||
name
==
"map.epsg.code"
||
name
==
"mapproj.epsg.code"
||
name
==
"mapproj.epsg.code"
||
name
==
"mode.epsg.code"
)
||
name
==
"mode.epsg.code"
)
{
{
qgis_type
=
"QgsProcessingParameterCrs"
;
qgis_type
=
"QgsProcessingParameterCrs"
;
isEpsgCode
=
true
;
isEpsgCode
=
true
;
}
}
dFile
<<
qgis_type
<<
"|"
<<
name
<<
"|"
<<
description
;
dFile
<<
qgis_type
<<
"|"
<<
name
<<
"|"
<<
description
;
std
::
string
default_value
=
"None"
;
std
::
string
default_value
=
"None"
;
if
(
type
==
ParameterType_Int
)
if
(
type
==
ParameterType_Int
)
{
{
if
(
isEpsgCode
)
if
(
isEpsgCode
)
{
{
if
(
param
->
HasValue
()
&&
appli
->
GetParameterInt
(
name
)
<
1
)
if
(
param
->
HasValue
()
&&
appli
->
GetParameterInt
(
name
)
<
1
)
default_value
=
"EPSG: "
+
appli
->
GetParameterAsString
(
name
);
default_value
=
"EPSG: "
+
appli
->
GetParameterAsString
(
name
);
else
else
default_value
=
"ProjectCrs"
;
default_value
=
"ProjectCrs"
;
}
}
else
{
dFile
<<
"|QgsProcessingParameterNumber.Integer"
;
default_value
=
param
->
HasValue
()
?
appli
->
GetParameterAsString
(
name
)
:
"0"
;
}
}
else
if
(
type
==
ParameterType_Float
)
{
dFile
<<
"|QgsProcessingParameterNumber.Double"
;
default_value
=
param
->
HasValue
()
?
appli
->
GetParameterAsString
(
name
)
:
"0"
;
}
else
if
(
type
==
ParameterType_Radius
)
{
dFile
<<
"|QgsProcessingParameterNumber.Integer"
;
default_value
=
param
->
HasValue
()
?
appli
->
GetParameterAsString
(
name
)
:
"0"
;
}
else
if
(
type
==
ParameterType_InputFilename
)
{
// TODO: if parameter InputFilename can give supported extensions
// we can use it gitlab #1559
dFile
<<
"|QgsProcessingParameterFile.File|txt"
;
}
else
if
(
type
==
ParameterType_Directory
)
{
dFile
<<
"|QgsProcessingParameterFile.Folder|False"
;
}
else
if
(
type
==
ParameterType_InputImageList
)
{
dFile
<<
"|3"
;
//QgsProcessing.TypeRaster
}
else
if
(
type
==
ParameterType_InputVectorDataList
)
{
dFile
<<
"|-1"
;
//QgsProcessing.TypeVectorAnyGeometry
}
else
if
(
type
==
ParameterType_InputVectorData
)
{
dFile
<<
"|-1"
;
//QgsProcessing.TypeVectorAnyGeometry
}
else
if
(
type
==
ParameterType_InputFilenameList
)
{
dFile
<<
"|4"
;
//QgsProcessing.TypeFile"
}
else
if
(
type
==
ParameterType_String
)
{
// Below line is interpreted in qgis processing as
// 1. default_value = None
// 2. multiLine = False
// For more details,
// please refer to documetation of QgsProcessingParameterString.
default_value
=
"None|False"
;
}
else
if
(
type
==
ParameterType_StringList
)
{
// Below line is interpreted in qgis processing as
// 1. default_value = None
// 2. multiLine = True
// For more details,
// please refer to documetation of QgsProcessingParameterString.
// setting default_value this way is an exception for ParameterType_StringList and ParameterType_String
default_value
=
"None|True"
;
}
else
if
(
type
==
ParameterType_InputImage
)
{
// default is None and nothing to add to dFile
}
else
if
(
type
==
ParameterType_ListView
)
{
// default is None and nothing to add to dFile
}
else
if
(
type
==
ParameterType_Bool
)
{
default_value
=
appli
->
GetParameterAsString
(
name
);
}
else
if
(
type
==
ParameterType_Choice
)
{
std
::
vector
<
std
::
string
>
key_list
=
appli
->
GetChoiceKeys
(
name
);
std
::
string
values
=
""
;
for
(
auto
k
:
key_list
)
values
+=
k
+
";"
;
values
.
pop_back
();
dFile
<<
"|"
<<
values
;
ChoiceParameter
*
cparam
=
dynamic_cast
<
ChoiceParameter
*>
(
param
.
GetPointer
());
default_value
=
std
::
to_string
(
cparam
->
GetValue
());
}
else
if
(
type
==
ParameterType_OutputVectorData
||
type
==
ParameterType_OutputImage
||
type
==
ParameterType_OutputFilename
)
{
// No need for default_value, optional and extra fields in dFile.
// If parameter is a destination type. qgis_type|name|description is enough.
// So we simply set isDestination to true and skip to end to append a new line.
isDestination
=
true
;
}
else
else
{
{
std
::
cout
<<
"ERROR: default_value is empty for '"
<<
name
<<
"' type='"
<<
qgis_type
<<
"'"
<<
std
::
endl
;
dFile
<<
"|QgsProcessingParameterNumber.Integer"
;
return
EXIT_FAILURE
;
default_value
=
param
->
HasValue
()
?
appli
->
GetParameterAsString
(
name
)
:
"0"
;
}
}
}
else
if
(
type
==
ParameterType_Float
)
{
dFile
<<
"|QgsProcessingParameterNumber.Double"
;
default_value
=
param
->
HasValue
()
?
appli
->
GetParameterAsString
(
name
)
:
"0"
;
}
else
if
(
type
==
ParameterType_Radius
)
{
dFile
<<
"|QgsProcessingParameterNumber.Integer"
;
default_value
=
param
->
HasValue
()
?
appli
->
GetParameterAsString
(
name
)
:
"0"
;
}
else
if
(
type
==
ParameterType_InputFilename
)
{
// TODO: if parameter InputFilename can give supported extensions
// we can use it gitlab #1559
dFile
<<
"|QgsProcessingParameterFile.File|txt"
;
}
else
if
(
type
==
ParameterType_Directory
)
{
dFile
<<
"|QgsProcessingParameterFile.Folder|False"
;
}
else
if
(
type
==
ParameterType_InputImageList
)
{
dFile
<<
"|3"
;
//QgsProcessing.TypeRaster
}
else
if
(
type
==
ParameterType_InputVectorDataList
)
{
dFile
<<
"|-1"
;
//QgsProcessing.TypeVectorAnyGeometry
}
else
if
(
type
==
ParameterType_InputVectorData
)
{
dFile
<<
"|-1"
;
//QgsProcessing.TypeVectorAnyGeometry
}
else
if
(
type
==
ParameterType_InputFilenameList
)
{
dFile
<<
"|4"
;
//QgsProcessing.TypeFile"
}
else
if
(
type
==
ParameterType_String
)
{
// Below line is interpreted in qgis processing as
// 1. default_value = None
// 2. multiLine = False
// For more details,
// please refer to documetation of QgsProcessingParameterString.
default_value
=
"None|False"
;
}
else
if
(
type
==
ParameterType_StringList
)
{
// Below line is interpreted in qgis processing as
// 1. default_value = None
// 2. multiLine = True
// For more details,
// please refer to documetation of QgsProcessingParameterString.
// setting default_value this way is an exception for ParameterType_StringList and ParameterType_String
default_value
=
"None|True"
;
}
else
if
(
type
==
ParameterType_InputImage
)
{
// default is None and nothing to add to dFile
}
else
if
(
type
==
ParameterType_ListView
)
{
// default is None and nothing to add to dFile
}
else
if
(
type
==
ParameterType_Bool
)
{
default_value
=
appli
->
GetParameterAsString
(
name
);
}
else
if
(
type
==
ParameterType_Choice
)
{
std
::
vector
<
std
::
string
>
key_list
=
appli
->
GetChoiceKeys
(
name
);
std
::
string
values
=
""
;
for
(
auto
k
:
key_list
)
values
+=
k
+
";"
;
if
(
!
isDestination
)
values
.
pop_back
();
{
dFile
<<
"|"
<<
values
;
std
::
string
optional
;
ChoiceParameter
*
cparam
=
dynamic_cast
<
ChoiceParameter
*>
(
param
.
GetPointer
());
if
(
param
->
GetMandatory
())
default_value
=
std
::
to_string
(
cparam
->
GetValue
());
{
}
// TODO: avoid workaround for stringlist types (fix appengine)
else
if
(
type
==
ParameterType_OutputVectorData
||
// type == ParameterType_StringList check is needed because:
type
==
ParameterType_OutputImage
||
// If parameter is mandatory it can have no value
type
==
ParameterType_OutputFilename
)
// It is accepted in OTB that, string list could be generated dynamically
{
// qgis has no such option to handle dynamic values yet..
// No need for default_value, optional and extra fields in dFile.
// So mandatory parameters whose type is StringList is considered optional
// If parameter is a destination type. qgis_type|name|description is enough.
optional
=
param
->
HasValue
()
||
type
==
ParameterType_StringList
?
"True"
:
"False"
;
// So we simply set isDestination to true and skip to end to append a new line.
}
isDestination
=
true
;
else
}
{
else
optional
=
"True"
;
{
}
std
::
cout
<<
"ERROR: default_value is empty for '"
<<
name
<<
"' type='"
<<
qgis_type
<<
"'"
<<
std
::
endl
;
#if 0
return
EXIT_FAILURE
;
std::cerr << name;
}
std::cerr << " mandatory=" << param->GetMandatory();
std::cerr << " HasValue=" << param->HasValue();
if
(
!
isDestination
)
std::cerr << " qgis_type=" << qgis_type;
{
std::cerr << " optional=" << optional << std::endl;
std
::
string
optional
;
#endif
if
(
param
->
GetMandatory
())
dFile
<<
"|"
<<
default_value
<<
"|"
<<
optional
;
{
}
// TODO: avoid workaround for stringlist types (fix appengine)
dFile
<<
std
::
endl
;
// type == ParameterType_StringList check is needed because:
}
// If parameter is mandatory it can have no value
// It is accepted in OTB that, string list could be generated dynamically
// qgis has no such option to handle dynamic values yet..
// So mandatory parameters whose type is StringList is considered optional
optional
=
param
->
HasValue
()
||
type
==
ParameterType_StringList
?
"True"
:
"False"
;
}
else
{
optional
=
"True"
;
}
#if 0
std::cerr << name;
std::cerr << " mandatory=" << param->GetMandatory();
std::cerr << " HasValue=" << param->HasValue();
std::cerr << " qgis_type=" << qgis_type;
std::cerr << " optional=" << optional << std::endl;
#endif
dFile
<<
"|"
<<
default_value
<<
"|"
<<
optional
;
}
dFile
<<
std
::
endl
;
}
if
(
hasRasterOutput
)
if
(
hasRasterOutput
)
{
{
dFile
<<
"*QgsProcessingParameterEnum|outputpixeltype|Output pixel type|unit8;int;float;double|False|2|True"
<<
std
::
endl
;
dFile
<<
"*QgsProcessingParameterEnum|outputpixeltype|Output pixel type|unit8;int;float;double|False|2|True"
<<
std
::
endl
;
}
}
dFile
.
close
();
dFile
.
close
();
...
@@ -344,6 +343,6 @@ int main(int argc, char* argv[])
...
@@ -344,6 +343,6 @@ int main(int argc, char* argv[])
indexFile
.
close
();
indexFile
.
close
();
std
::
cerr
<<
"Updated "
<<
algs_txt
<<
std
::
endl
;
std
::
cerr
<<
"Updated "
<<
algs_txt
<<
std
::
endl
;
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
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