27 #include <QProgressDialog>
32 , mTriangleInterpolator( 0 )
33 , mIsInitialized( false )
34 , mShowProgressDialog( showProgressDialog )
35 , mExportTriangulationToFile( false )
36 , mInterpolation( interpolation )
42 delete mTriangulation;
43 delete mTriangleInterpolator;
48 if ( !mIsInitialized )
53 if ( !mTriangleInterpolator )
59 if ( !mTriangleInterpolator->
calcPoint( x, y, &r ) )
67 void QgsTINInterpolator::initialize()
78 mTriangulation = theDualEdgeTriangulation;
83 int nProcessedFeatures = 0;
84 if ( mShowProgressDialog )
86 QList<LayerData>::iterator layerDataIt =
mLayerData.begin();
87 for ( ; layerDataIt !=
mLayerData.end(); ++layerDataIt )
89 if ( layerDataIt->vectorLayer )
91 nFeatures += layerDataIt->vectorLayer->featureCount();
96 QProgressDialog* theProgressDialog = 0;
97 if ( mShowProgressDialog )
99 theProgressDialog =
new QProgressDialog(
QObject::tr(
"Building triangulation..." ),
QObject::tr(
"Abort" ), 0, nFeatures, 0 );
100 theProgressDialog->setWindowModality( Qt::WindowModal );
105 QList<LayerData>::iterator layerDataIt =
mLayerData.begin();
106 for ( ; layerDataIt !=
mLayerData.end(); ++layerDataIt )
108 if ( layerDataIt->vectorLayer )
111 if ( !layerDataIt->zCoordInterpolation )
113 attList.push_back( layerDataIt->interpolationAttribute );
120 if ( mShowProgressDialog )
122 if ( theProgressDialog->wasCanceled() )
126 theProgressDialog->setValue( nProcessedFeatures );
128 insertData( &f, layerDataIt->zCoordInterpolation, layerDataIt->interpolationAttribute, layerDataIt->mInputType );
129 ++nProcessedFeatures;
134 delete theProgressDialog;
142 QProgressDialog* progressDialog = 0;
143 if ( mShowProgressDialog )
145 progressDialog =
new QProgressDialog();
146 progressDialog->setLabelText(
QObject::tr(
"Estimating normal derivatives..." ) );
149 delete progressDialog;
152 mTriangleInterpolator = ctInterpolator;
159 mIsInitialized =
true;
162 if ( mExportTriangulationToFile )
168 int QgsTINInterpolator::insertData(
QgsFeature* f,
bool zCoord,
int attr, InputType type )
184 double attributeValue = 0;
185 bool attributeConversionOk =
false;
188 QVariant attributeVariant = f->
attribute( attr );
189 if ( !attributeVariant.isValid() )
193 attributeValue = attributeVariant.toDouble( &attributeConversionOk );
194 if ( !attributeConversionOk || qIsNaN( attributeValue ) )
201 bool hasZValue =
false;
214 currentWkbPtr >> x >> y;
215 if ( zCoord && hasZValue )
224 if ( mTriangulation->
addPoint( thePoint ) == -100 )
235 currentWkbPtr >> nPoints;
238 currentWkbPtr += 1 +
sizeof( int );
239 currentWkbPtr >> x >> y;
260 currentWkbPtr >> nPoints;
263 currentWkbPtr >> x >> y;
264 if ( zCoord && hasZValue )
295 currentWkbPtr >> nLines;
303 currentWkbPtr >> nPoints;
304 for (
int index2 = 0; index2 < nPoints; ++index2 )
306 currentWkbPtr >> x >> y;
338 currentWkbPtr >> nRings;
347 currentWkbPtr >> nPoints;
348 for (
int index2 = 0; index2 < nPoints; ++index2 )
350 currentWkbPtr >> x >> y;
383 currentWkbPtr >> nPolys;
386 currentWkbPtr += 1 +
sizeof( int );
388 currentWkbPtr >> nRings;
389 for (
int index2 = 0; index2 < nRings; ++index2 )
396 currentWkbPtr >> nPoints;
397 for (
int index3 = 0; index3 < nPoints; ++index3 )
399 currentWkbPtr >> x >> y;