Skip to content

Commit

Permalink
[processing] use hours as cost units for service area algorithms (fix #…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Apr 30, 2020
1 parent 74aa54b commit cfcaaef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/analysis/processing/qgsalgorithmserviceareafromlayer.cpp
Expand Up @@ -39,7 +39,11 @@ QStringList QgsServiceAreaFromLayerAlgorithm::tags() const

QString QgsServiceAreaFromLayerAlgorithm::shortHelpString() const
{
return QObject::tr( "This algorithm creates a new vector with all the edges or parts of edges of a network line layer that can be reached within a distance or a time, starting from features of a point layer. The distance and the time (both referred to as \"travel cost\") must be specified respectively in the network layer units or in seconds." );
return QObject::tr( "This algorithm creates a new vector with all the edges or parts of "
"edges of a network line layer that can be reached within a distance "
"or a time, starting from features of a point layer. The distance and "
"the time (both referred to as \"travel cost\") must be specified "
"respectively in the network layer units or in hours." );
}

QgsServiceAreaFromLayerAlgorithm *QgsServiceAreaFromLayerAlgorithm::createInstance() const
Expand Down Expand Up @@ -79,6 +83,10 @@ QVariantMap QgsServiceAreaFromLayerAlgorithm::processAlgorithm( const QVariantMa

double travelCost = parameterAsDouble( parameters, QStringLiteral( "TRAVEL_COST" ), context );

int strategy = parameterAsInt( parameters, QStringLiteral( "STRATEGY" ), context );
if ( strategy )
travelCost *= mMultiplier;

bool includeBounds = true; // default to true to maintain 3.0 API
if ( parameters.contains( QStringLiteral( "INCLUDE_BOUNDS" ) ) )
{
Expand Down
10 changes: 9 additions & 1 deletion src/analysis/processing/qgsalgorithmserviceareafrompoint.cpp
Expand Up @@ -39,7 +39,11 @@ QStringList QgsServiceAreaFromPointAlgorithm::tags() const

QString QgsServiceAreaFromPointAlgorithm::shortHelpString() const
{
return QObject::tr( "This algorithm creates a new vector with all the edges or parts of edges of a network line layer that can be reached within a distance or a time, starting from a point feature. The distance and the time (both referred to as \"travel cost\") must be specified respectively in the network layer units or in seconds." );
return QObject::tr( "This algorithm creates a new vector with all the edges or parts of edges "
"of a network line layer that can be reached within a distance or a time, "
"starting from a point feature. The distance and the time (both referred to "
"as \"travel cost\") must be specified respectively in the network layer "
"units or in hours." );
}

QgsServiceAreaFromPointAlgorithm *QgsServiceAreaFromPointAlgorithm::createInstance() const
Expand Down Expand Up @@ -76,6 +80,10 @@ QVariantMap QgsServiceAreaFromPointAlgorithm::processAlgorithm( const QVariantMa
QgsPointXY startPoint = parameterAsPoint( parameters, QStringLiteral( "START_POINT" ), context, mNetwork->sourceCrs() );
double travelCost = parameterAsDouble( parameters, QStringLiteral( "TRAVEL_COST" ), context );

int strategy = parameterAsInt( parameters, QStringLiteral( "STRATEGY" ), context );
if ( strategy )
travelCost *= mMultiplier;

bool includeBounds = true; // default to true to maintain 3.0 API
if ( parameters.contains( QStringLiteral( "INCLUDE_BOUNDS" ) ) )
{
Expand Down

0 comments on commit cfcaaef

Please sign in to comment.