25 : mDataIsCached( false )
26 , mLayerData( layerData )
31 QgsInterpolator::QgsInterpolator()
32 : mDataIsCached( false )
57 if ( v_it->vectorLayer == 0 )
69 if ( !v_it->zCoordInterpolation )
71 attList.
push_back( v_it->interpolationAttribute );
75 double attributeValue = 0.0;
76 bool attributeConversionOk =
false;
83 if ( !v_it->zCoordInterpolation )
86 if ( !attributeVariant.
isValid() )
90 attributeValue = attributeVariant.
toDouble( &attributeConversionOk );
91 if ( !attributeConversionOk || qIsNaN( attributeValue ) )
97 if ( addVerticesToCache( theFeature.
constGeometry(), v_it->zCoordInterpolation, attributeValue ) != 0 )
107 int QgsInterpolator::addVerticesToCache(
const QgsGeometry *geom,
bool zCoord,
double attributeValue )
112 bool hasZValue =
false;
124 currentWkbPtr >> theVertex.
x >> theVertex.
y;
125 if ( zCoord && hasZValue )
127 currentWkbPtr >> theVertex.
z;
131 theVertex.
z = attributeValue;
142 currentWkbPtr >> nPoints;
145 currentWkbPtr >> theVertex.
x >> theVertex.
y;
146 if ( zCoord && hasZValue )
148 currentWkbPtr >> theVertex.
z;
152 theVertex.
z = attributeValue;
170 for (
int index2 = 0; index2 < *npoints; ++index2 )
174 if ( point.sqrDist( x, y ) < actdist )
176 actdist = point.sqrDist( x, y );
177 vertexnr = vertexcounter;
181 beforeVertex = vertexcounter + ( *npoints - 2 );
182 afterVertex = vertexcounter + 1;
184 else if ( index2 == ( *npoints - 1 ) )
186 beforeVertex = vertexcounter - 1;
187 afterVertex = vertexcounter - ( *npoints - 2 );
191 beforeVertex = vertexcounter - 1;
192 afterVertex = vertexcounter + 1;
197 wkbPtr +=
sizeof( double );
213 wkbPtr += 1 +
sizeof( int );
217 if ( point.sqrDist( x, y ) < actdist )
219 actdist = point.sqrDist( x, y );
224 wkbPtr +=
sizeof( double );
240 for (
int index2 = 0; index2 < nPoints; ++index2 )
244 if ( point.sqrDist( x, y ) < actdist )
246 actdist = point.sqrDist( x, y );
247 vertexnr = vertexcounter;
255 beforeVertex = vertexnr - 1;
257 if ( index2 == nPoints - 1 )
263 afterVertex = vertexnr + 1;
268 wkbPtr +=
sizeof( double );
284 wkbPtr += 1 +
sizeof( int );
287 for (
int index2 = 0; index2 < nRings; ++index2 )
291 for (
int index3 = 0; index3 < nPoints; ++index3 )
295 if ( point.sqrDist( x, y ) < actdist )
297 actdist = point.sqrDist( x, y );
298 vertexnr = vertexcounter;
303 beforeVertex = vertexcounter + ( nPoints - 2 );
304 afterVertex = vertexcounter + 1;
306 else if ( index3 == ( *npoints - 1 ) )
308 beforeVertex = vertexcounter - 1;
309 afterVertex = vertexcounter - ( nPoints - 2 );
313 beforeVertex = vertexcounter - 1;
314 afterVertex = vertexcounter + 1;
319 wkbPtr +=
sizeof( double );
Wrapper for iterator of features from vector data provider or vector layer.
QList< LayerData > mLayerData
QVector< vertexData > mCachedBaseData
void push_back(const T &value)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
A geometry is the spatial representation of a feature.
WkbType
Used for symbology operations.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual ~QgsInterpolator()
bool mDataIsCached
Flag that tells if the cache already has been filled.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
QgsInterpolator(const QList< LayerData > &layerData)
void push_back(const T &value)
double toDouble(bool *ok) const
bool nextFeature(QgsFeature &f)
Represents a vector layer which manages a vector based data sets.
const unsigned char * asWkb() const
Returns the buffer containing this geometry in WKB format.
int cacheBaseData()
Caches the vertex and value data from the provider.