19 : mAttributeId( attributeId )
20 , mDefaultValue( defaultValue )
21 , mToMetricFactor( toMetricFactor )
27 double speed = mDefaultValue;
29 if ( mAttributeId >= 0 && mAttributeId < attrs.count() )
31 const QVariant value = attrs.at( mAttributeId );
34 speed = attrs.at( mAttributeId ).toDouble();
36 speed = mDefaultValue;
40 return distance / ( speed * mToMetricFactor );
46 if ( mAttributeId >= 0 )
47 l.insert( mAttributeId );
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
QVariant cost(double distance, const QgsFeature &f) const override
Returns edge cost.
QgsNetworkSpeedStrategy(int attributeId, double defaultValue, double toMetricFactor)
Default constructor.
QSet< int > requiredAttributes() const override
Returns a list of the source layer attributes needed for cost calculation.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.