Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Main Repositories
otb
Commits
2223f63d
Commit
2223f63d
authored
Feb 19, 2016
by
Guillaume Pasero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: handle geometry collections
parent
a25ac627
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
10 deletions
+44
-10
Modules/Learning/Sampling/include/otbPolygonClassStatisticsAccumulator.h
...g/Sampling/include/otbPolygonClassStatisticsAccumulator.h
+6
-0
Modules/Learning/Sampling/include/otbPolygonClassStatisticsAccumulator.txx
...Sampling/include/otbPolygonClassStatisticsAccumulator.txx
+38
-10
No files found.
Modules/Learning/Sampling/include/otbPolygonClassStatisticsAccumulator.h
View file @
2223f63d
...
...
@@ -73,6 +73,12 @@ private:
PolygonSizeMapType
m_Polygon
;
// check the feature id
int
m_FieldIndex
;
template
<
typename
TIterator
>
void
AddGeometry
(
OGRGeometry
*
geom
,
TIterator
&
imgIt
,
unsigned
long
&
fId
,
std
::
string
&
className
);
// Not implemented
PolygonClassStatisticsAccumulator
(
const
Self
&
);
...
...
Modules/Learning/Sampling/include/otbPolygonClassStatisticsAccumulator.txx
View file @
2223f63d
...
...
@@ -43,12 +43,25 @@ PolygonClassStatisticsAccumulator
{
m_Polygon[featureId] = 0UL;
}
this->AddGeometry(featIt->ogr().GetGeometryRef(),
imgIt,
featureId,
className);
}
template <typename TIterator>
void
PolygonClassStatisticsAccumulator
::AddGeometry(OGRGeometry *geom,
TIterator& imgIt,
unsigned long &fId,
std::string &className)
{
typename TIterator::ImageType::PointType imgPoint;
typename TIterator::IndexType imgIndex;
OGRPoint tmpPoint(0.0,0.0,0.0);
imgIt.GoToBegin();
OGRGeometry * geom = featIt->ogr().GetGeometryRef();
switch (geom->getGeometryType())
{
case wkbPoint:
...
...
@@ -69,7 +82,7 @@ PolygonClassStatisticsAccumulator
{
m_NbPixelsGlobal++;
m_ElmtsInClass[className]++;
m_Polygon[f
eature
Id]++;
m_Polygon[fId]++;
break;
}
}
...
...
@@ -93,23 +106,23 @@ PolygonClassStatisticsAccumulator
while (!imgIt.IsAtEnd())
{
imgIt.GetImageIterator().GetImage()->TransformIndexToPhysicalPoint(imgIt.GetIndex(),imgPoint);
ring.
setPoint(0
tmpPolygon.getExteriorRing()->
setPoint(0
,imgPoint[0]-0.5*imgAbsSpacing[0]
,imgPoint[1]-0.5*imgAbsSpacing[1]
,0.0);
ring.
setPoint(1
tmpPolygon.getExteriorRing()->
setPoint(1
,imgPoint[0]+0.5*imgAbsSpacing[0]
,imgPoint[1]-0.5*imgAbsSpacing[1]
,0.0);
ring.
setPoint(2
tmpPolygon.getExteriorRing()->
setPoint(2
,imgPoint[0]+0.5*imgAbsSpacing[0]
,imgPoint[1]+0.5*imgAbsSpacing[1]
,0.0);
ring.
setPoint(3
tmpPolygon.getExteriorRing()->
setPoint(3
,imgPoint[0]-0.5*imgAbsSpacing[0]
,imgPoint[1]+0.5*imgAbsSpacing[1]
,0.0);
ring.
setPoint(4
tmpPolygon.getExteriorRing()->
setPoint(4
,imgPoint[0]-0.5*imgAbsSpacing[0]
,imgPoint[1]-0.5*imgAbsSpacing[1]
,0.0);
...
...
@@ -117,7 +130,7 @@ PolygonClassStatisticsAccumulator
{
m_NbPixelsGlobal++;
m_ElmtsInClass[className]++;
m_Polygon[f
eature
Id]++;
m_Polygon[fId]++;
}
++imgIt;
}
...
...
@@ -135,7 +148,7 @@ PolygonClassStatisticsAccumulator
{
m_NbPixelsGlobal++;
m_ElmtsInClass[className]++;
m_Polygon[f
eature
Id]++;
m_Polygon[fId]++;
}
++imgIt;
}
...
...
@@ -150,7 +163,22 @@ PolygonClassStatisticsAccumulator
case wkbGeometryCollection:
case wkbGeometryCollection25D:
{
otbWarningMacro("Geometry not handled: " << geom->getGeometryName());
OGRGeometryCollection *geomCollection = dynamic_cast<OGRGeometryCollection*>(geom);
if (geomCollection)
{
int nbGeom = geomCollection->getNumGeometries();
for (unsigned int i=0 ; i < nbGeom ; ++i)
{
this->AddGeometry(geomCollection->getGeometryRef(i),
imgIt,
fId,
className);
}
}
else
{
otbWarningMacro("Geometry not recognized as a collection : " << geom->getGeometryName());
}
break;
}
default:
...
...
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