Skip to content
Permalink
Browse files
Make TIN interpolation more robust in case of NULL values and data di…
…stribution on lines. Minor change in qgsvectordataprovider.cpp to directly request a const iterator

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10904 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jun 11, 2009
1 parent 23ae11e commit 6c14e34
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
@@ -222,7 +222,7 @@ int QgsVectorDataProvider::fieldNameIndex( const QString& fieldName ) const
{
const QgsFieldMap &theFields = fields();

for ( QgsFieldMap::const_iterator it = theFields.begin(); it != theFields.end(); ++it )
for ( QgsFieldMap::const_iterator it = theFields.constBegin(); it != theFields.constEnd(); ++it )
{
if ( it->name() == fieldName )
{
@@ -93,9 +93,9 @@ int QgsInterpolator::cacheBaseData()
{
QgsAttributeMap attMap = theFeature.attributeMap();
QgsAttributeMap::const_iterator att_it = attMap.find( mValueAttribute );
if ( att_it == attMap.end() ) //attribute not found, something must be wrong
if ( att_it == attMap.end() ) //attribute not found, something must be wrong (e.g. NULL value)
{
return 3;
continue;
}
attributeValue = att_it.value().toDouble( &attributeConversionOk );
if ( !attributeConversionOk || isnan( attributeValue ) ) //don't consider vertices with attributes like 'nan' for the interpolation
@@ -60,6 +60,8 @@ void QgsTINInterpolator::initialize()
cacheBaseData();
}

QList<Point3D*> rejectedPoints;

//create DualEdgeTriangulation

DualEdgeTriangulation* theDualEdgeTriangulation = new DualEdgeTriangulation( mCachedBaseData.size(), 0 );
@@ -70,7 +72,16 @@ void QgsTINInterpolator::initialize()
for ( ; vertex_it != mCachedBaseData.constEnd(); ++vertex_it )
{
Point3D* thePoint = new Point3D( vertex_it->x, vertex_it->y, vertex_it->z );
mTriangulation->addPoint( thePoint );
if(mTriangulation->addPoint( thePoint ) == -100)
{
rejectedPoints.push_back(new Point3D(vertex_it->x, vertex_it->y, vertex_it->z));
}
}

QList<Point3D*>::iterator rejectedIt = rejectedPoints.begin();
for(; rejectedIt != rejectedPoints.end(); ++rejectedIt)
{
mTriangulation->addPoint(*rejectedIt);
}

mTriangleInterpolator = new LinTriangleInterpolator( theDualEdgeTriangulation );

0 comments on commit 6c14e34

Please sign in to comment.