24 : mDataIsCached( false )
25 , mLayerData( layerData )
30 QgsInterpolator::QgsInterpolator()
31 : mDataIsCached( false )
52 QList<LayerData>::iterator v_it =
mLayerData.begin();
56 if ( v_it->vectorLayer == 0 )
68 if ( !v_it->zCoordInterpolation )
70 attList.push_back( v_it->interpolationAttribute );
74 double attributeValue = 0.0;
75 bool attributeConversionOk =
false;
82 if ( !v_it->zCoordInterpolation )
84 QVariant attributeVariant = theFeature.
attribute( v_it->interpolationAttribute );
85 if ( !attributeVariant.isValid() )
89 attributeValue = attributeVariant.toDouble( &attributeConversionOk );
90 if ( !attributeConversionOk || qIsNaN( attributeValue ) )
96 if ( addVerticesToCache( theFeature.
geometry(), v_it->zCoordInterpolation, attributeValue ) != 0 )
106 int QgsInterpolator::addVerticesToCache(
QgsGeometry* geom,
bool zCoord,
double attributeValue )
111 bool hasZValue =
false;
123 currentWkbPtr >> theVertex.
x >> theVertex.
y;
124 if ( zCoord && hasZValue )
126 currentWkbPtr >> theVertex.
z;
130 theVertex.
z = attributeValue;
141 currentWkbPtr >> nPoints;
144 currentWkbPtr >> theVertex.
x >> theVertex.
y;
145 if ( zCoord && hasZValue )
147 currentWkbPtr >> theVertex.
z;
151 theVertex.
z = attributeValue;
169 for (
int index2 = 0; index2 < *npoints; ++index2 )
173 if ( point.sqrDist( x, y ) < actdist )
175 actdist = point.sqrDist( x, y );
176 vertexnr = vertexcounter;
180 beforeVertex = vertexcounter + ( *npoints - 2 );
181 afterVertex = vertexcounter + 1;
183 else if ( index2 == ( *npoints - 1 ) )
185 beforeVertex = vertexcounter - 1;
186 afterVertex = vertexcounter - ( *npoints - 2 );
190 beforeVertex = vertexcounter - 1;
191 afterVertex = vertexcounter + 1;
196 wkbPtr +=
sizeof( double );
212 wkbPtr += 1 +
sizeof( int );
216 if ( point.sqrDist( x, y ) < actdist )
218 actdist = point.sqrDist( x, y );
223 wkbPtr +=
sizeof( double );
239 for (
int index2 = 0; index2 < nPoints; ++index2 )
243 if ( point.sqrDist( x, y ) < actdist )
245 actdist = point.sqrDist( x, y );
246 vertexnr = vertexcounter;
254 beforeVertex = vertexnr - 1;
256 if ( index2 == nPoints - 1 )
262 afterVertex = vertexnr + 1;
267 wkbPtr +=
sizeof( double );
283 wkbPtr += 1 +
sizeof( int );
286 for (
int index2 = 0; index2 < nRings; ++index2 )
290 for (
int index3 = 0; index3 < nPoints; ++index3 )
294 if ( point.sqrDist( x, y ) < actdist )
296 actdist = point.sqrDist( x, y );
297 vertexnr = vertexcounter;
302 beforeVertex = vertexcounter + ( nPoints - 2 );
303 afterVertex = vertexcounter + 1;
305 else if ( index3 == ( *npoints - 1 ) )
307 beforeVertex = vertexcounter - 1;
308 afterVertex = vertexcounter - ( nPoints - 2 );
312 beforeVertex = vertexcounter - 1;
313 afterVertex = vertexcounter + 1;
318 wkbPtr +=
sizeof( double );