Skip to content

Commit bc576b1

Browse files
author
mhugent
committed
Make TIN interpolation more robust in case of NULL values and data distribution on lines. Minor change in qgsvectordataprovider.cpp to directly request a const iterator
git-svn-id: http://svn.osgeo.org/qgis/trunk@10904 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 5975031 commit bc576b1

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/core/qgsvectordataprovider.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ int QgsVectorDataProvider::fieldNameIndex( const QString& fieldName ) const
222222
{
223223
const QgsFieldMap &theFields = fields();
224224

225-
for ( QgsFieldMap::const_iterator it = theFields.begin(); it != theFields.end(); ++it )
225+
for ( QgsFieldMap::const_iterator it = theFields.constBegin(); it != theFields.constEnd(); ++it )
226226
{
227227
if ( it->name() == fieldName )
228228
{

src/plugins/interpolation/qgsinterpolator.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ int QgsInterpolator::cacheBaseData()
9393
{
9494
QgsAttributeMap attMap = theFeature.attributeMap();
9595
QgsAttributeMap::const_iterator att_it = attMap.find( mValueAttribute );
96-
if ( att_it == attMap.end() ) //attribute not found, something must be wrong
96+
if ( att_it == attMap.end() ) //attribute not found, something must be wrong (e.g. NULL value)
9797
{
98-
return 3;
98+
continue;
9999
}
100100
attributeValue = att_it.value().toDouble( &attributeConversionOk );
101101
if ( !attributeConversionOk || isnan( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation

src/plugins/interpolation/qgstininterpolator.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ void QgsTINInterpolator::initialize()
6060
cacheBaseData();
6161
}
6262

63+
QList<Point3D*> rejectedPoints;
64+
6365
//create DualEdgeTriangulation
6466

6567
DualEdgeTriangulation* theDualEdgeTriangulation = new DualEdgeTriangulation( mCachedBaseData.size(), 0 );
@@ -70,7 +72,16 @@ void QgsTINInterpolator::initialize()
7072
for ( ; vertex_it != mCachedBaseData.constEnd(); ++vertex_it )
7173
{
7274
Point3D* thePoint = new Point3D( vertex_it->x, vertex_it->y, vertex_it->z );
73-
mTriangulation->addPoint( thePoint );
75+
if(mTriangulation->addPoint( thePoint ) == -100)
76+
{
77+
rejectedPoints.push_back(new Point3D(vertex_it->x, vertex_it->y, vertex_it->z));
78+
}
79+
}
80+
81+
QList<Point3D*>::iterator rejectedIt = rejectedPoints.begin();
82+
for(; rejectedIt != rejectedPoints.end(); ++rejectedIt)
83+
{
84+
mTriangulation->addPoint(*rejectedIt);
7485
}
7586

7687
mTriangleInterpolator = new LinTriangleInterpolator( theDualEdgeTriangulation );

0 commit comments

Comments
 (0)