Skip to content

Commit

Permalink
Make TIN interpolation more robust in case of NULL values and data di…
Browse files Browse the repository at this point in the history
…stribution 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
  • Loading branch information
mhugent committed Jun 11, 2009
1 parent 5975031 commit bc576b1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/qgsvectordataprovider.cpp
Expand Up @@ -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 )
{
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/interpolation/qgsinterpolator.cpp
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion src/plugins/interpolation/qgstininterpolator.cpp
Expand Up @@ -60,6 +60,8 @@ void QgsTINInterpolator::initialize()
cacheBaseData();
}

QList<Point3D*> rejectedPoints;

//create DualEdgeTriangulation

DualEdgeTriangulation* theDualEdgeTriangulation = new DualEdgeTriangulation( mCachedBaseData.size(), 0 );
Expand All @@ -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 );
Expand Down

0 comments on commit bc576b1

Please sign in to comment.