Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
otb
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
213
Issues
213
List
Boards
Labels
Milestones
Merge Requests
11
Merge Requests
11
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Main Repositories
otb
Commits
26a6ca68
Commit
26a6ca68
authored
Nov 22, 2019
by
guillaume pernot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed lost reference of "buffer" in VectorPrediction update mode
parent
8700c3a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
32 deletions
+44
-32
Modules/Applications/AppClassification/include/otbVectorPrediction.h
...lications/AppClassification/include/otbVectorPrediction.h
+5
-3
Modules/Applications/AppClassification/include/otbVectorPrediction.hxx
...cations/AppClassification/include/otbVectorPrediction.hxx
+39
-29
No files found.
Modules/Applications/AppClassification/include/otbVectorPrediction.h
View file @
26a6ca68
...
...
@@ -104,9 +104,11 @@ private:
/** Normalize a list sample using the statistic file given */
typename
ListSampleType
::
Pointer
NormalizeListSample
(
ListSampleType
::
Pointer
input
);
/** Create the output DataSource, in update mode the input layer is buffered and the input
* data source is re opened in update mode. */
otb
::
ogr
::
DataSource
::
Pointer
CreateOutputDataSource
(
otb
::
ogr
::
DataSource
::
Pointer
source
,
otb
::
ogr
::
Layer
&
layer
,
bool
updateMode
);
/** Update the output DataSource : the input layer is buffered and the input data source is re opened in update mode. */
otb
::
ogr
::
DataSource
::
Pointer
UpdateOutputDataSource
(
otb
::
ogr
::
DataSource
::
Pointer
source
,
otb
::
ogr
::
Layer
&
layer
,
otb
::
ogr
::
DataSource
::
Pointer
buffer
);
/** Create the output DataSource. */
otb
::
ogr
::
DataSource
::
Pointer
CreateOutputDataSource
(
otb
::
ogr
::
DataSource
::
Pointer
source
,
otb
::
ogr
::
Layer
&
layer
);
/** Add a prediction field in the output layer if it does not exist.
* If computeConfidenceMap evaluates to true a confidence field will be
...
...
Modules/Applications/AppClassification/include/otbVectorPrediction.hxx
View file @
26a6ca68
...
...
@@ -147,41 +147,39 @@ typename VectorPrediction<RegressionMode>::ListSampleType::Pointer VectorPredict
template
<
bool
RegressionMode
>
otb
::
ogr
::
DataSource
::
Pointer
VectorPrediction
<
RegressionMode
>::
Cre
ateOutputDataSource
(
otb
::
ogr
::
DataSource
::
Pointer
source
,
otb
::
ogr
::
Layer
&
layer
,
bool
updateMode
)
otb
::
ogr
::
DataSource
::
Pointer
VectorPrediction
<
RegressionMode
>::
Upd
ateOutputDataSource
(
otb
::
ogr
::
DataSource
::
Pointer
source
,
otb
::
ogr
::
Layer
&
layer
,
ogr
::
DataSource
::
Pointer
buffer
)
{
ogr
::
DataSource
::
Pointer
output
;
ogr
::
DataSource
::
Pointer
buffer
=
ogr
::
DataSource
::
New
();
if
(
updateMode
)
{
// Update mode
otbAppLogINFO
(
"Update input vector data."
);
// fill temporary buffer for the transfer
otb
::
ogr
::
Layer
inputLayer
=
layer
;
layer
=
buffer
->
CopyLayer
(
inputLayer
,
std
::
string
(
"Buffer"
));
// close input data source
source
->
Clear
();
// Re-open input data source in update mode
output
=
otb
::
ogr
::
DataSource
::
New
(
GetParameterString
(
"in"
),
otb
::
ogr
::
DataSource
::
Modes
::
Update_LayerUpdate
);
}
else
// Update mode
otbAppLogINFO
(
"Update input vector data."
);
// fill temporary buffer for the transfer
otb
::
ogr
::
Layer
inputLayer
=
layer
;
layer
=
buffer
->
CopyLayer
(
inputLayer
,
std
::
string
(
"Buffer"
));
// close input data source
source
->
Clear
();
// Re-open input data source in update mode
output
=
otb
::
ogr
::
DataSource
::
New
(
GetParameterString
(
"in"
),
otb
::
ogr
::
DataSource
::
Modes
::
Update_LayerUpdate
);
return
output
;
}
template
<
bool
RegressionMode
>
otb
::
ogr
::
DataSource
::
Pointer
VectorPrediction
<
RegressionMode
>::
CreateOutputDataSource
(
otb
::
ogr
::
DataSource
::
Pointer
source
,
otb
::
ogr
::
Layer
&
layer
)
{
ogr
::
DataSource
::
Pointer
output
;
// Create new OGRDataSource
output
=
ogr
::
DataSource
::
New
(
GetParameterString
(
"out"
),
ogr
::
DataSource
::
Modes
::
Overwrite
);
otb
::
ogr
::
Layer
newLayer
=
output
->
CreateLayer
(
GetParameterString
(
"out"
),
const_cast
<
OGRSpatialReference
*>
(
layer
.
GetSpatialRef
()),
layer
.
GetGeomType
());
// Copy existing fields
OGRFeatureDefn
&
inLayerDefn
=
layer
.
GetLayerDefn
();
for
(
int
k
=
0
;
k
<
inLayerDefn
.
GetFieldCount
();
k
++
)
{
// Create new OGRDataSource
output
=
ogr
::
DataSource
::
New
(
GetParameterString
(
"out"
),
ogr
::
DataSource
::
Modes
::
Overwrite
);
otb
::
ogr
::
Layer
newLayer
=
output
->
CreateLayer
(
GetParameterString
(
"out"
),
const_cast
<
OGRSpatialReference
*>
(
layer
.
GetSpatialRef
()),
layer
.
GetGeomType
());
// Copy existing fields
OGRFeatureDefn
&
inLayerDefn
=
layer
.
GetLayerDefn
();
for
(
int
k
=
0
;
k
<
inLayerDefn
.
GetFieldCount
();
k
++
)
{
OGRFieldDefn
fieldDefn
(
inLayerDefn
.
GetFieldDefn
(
k
));
newLayer
.
CreateField
(
fieldDefn
);
}
OGRFieldDefn
fieldDefn
(
inLayerDefn
.
GetFieldDefn
(
k
));
newLayer
.
CreateField
(
fieldDefn
);
}
return
output
;
}
template
<
bool
RegressionMode
>
void
VectorPrediction
<
RegressionMode
>::
AddPredictionField
(
otb
::
ogr
::
Layer
&
outLayer
,
otb
::
ogr
::
Layer
const
&
layer
,
bool
computeConfidenceMap
)
{
...
...
@@ -306,7 +304,19 @@ void VectorPrediction<RegressionMode>::DoExecute()
const
bool
updateMode
=
!
(
IsParameterEnabled
(
"out"
)
&&
HasValue
(
"out"
));
auto
output
=
CreateOutputDataSource
(
source
,
layer
,
updateMode
);
ogr
::
DataSource
::
Pointer
buffer
;
otb
::
ogr
::
DataSource
::
Pointer
output
;
if
(
updateMode
)
{
buffer
=
ogr
::
DataSource
::
New
();
output
=
UpdateOutputDataSource
(
source
,
layer
,
buffer
);
}
else
{
output
=
CreateOutputDataSource
(
source
,
layer
);
}
otb
::
ogr
::
Layer
outLayer
=
output
->
GetLayer
(
0
);
OGRErr
errStart
=
outLayer
.
ogr
().
StartTransaction
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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