[QGIS Commit] r10904 - in trunk/qgis/src: core plugins/interpolation
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Thu Jun 11 10:45:38 EDT 2009
Author: mhugent
Date: 2009-06-11 10:45:38 -0400 (Thu, 11 Jun 2009)
New Revision: 10904
Modified:
trunk/qgis/src/core/qgsvectordataprovider.cpp
trunk/qgis/src/plugins/interpolation/qgsinterpolator.cpp
trunk/qgis/src/plugins/interpolation/qgstininterpolator.cpp
Log:
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
Modified: trunk/qgis/src/core/qgsvectordataprovider.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectordataprovider.cpp 2009-06-11 11:54:43 UTC (rev 10903)
+++ trunk/qgis/src/core/qgsvectordataprovider.cpp 2009-06-11 14:45:38 UTC (rev 10904)
@@ -222,7 +222,7 @@
{
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 )
{
Modified: trunk/qgis/src/plugins/interpolation/qgsinterpolator.cpp
===================================================================
--- trunk/qgis/src/plugins/interpolation/qgsinterpolator.cpp 2009-06-11 11:54:43 UTC (rev 10903)
+++ trunk/qgis/src/plugins/interpolation/qgsinterpolator.cpp 2009-06-11 14:45:38 UTC (rev 10904)
@@ -93,9 +93,9 @@
{
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
Modified: trunk/qgis/src/plugins/interpolation/qgstininterpolator.cpp
===================================================================
--- trunk/qgis/src/plugins/interpolation/qgstininterpolator.cpp 2009-06-11 11:54:43 UTC (rev 10903)
+++ trunk/qgis/src/plugins/interpolation/qgstininterpolator.cpp 2009-06-11 14:45:38 UTC (rev 10904)
@@ -60,6 +60,8 @@
cacheBaseData();
}
+ QList<Point3D*> rejectedPoints;
+
//create DualEdgeTriangulation
DualEdgeTriangulation* theDualEdgeTriangulation = new DualEdgeTriangulation( mCachedBaseData.size(), 0 );
@@ -70,9 +72,18 @@
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 );
mIsInitialized = true;
More information about the QGIS-commit
mailing list