Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
rename enum and its values
  • Loading branch information
alexbruy committed Nov 21, 2016
1 parent 9dffe64 commit d657c77
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 37 deletions.
10 changes: 5 additions & 5 deletions python/analysis/network/qgslinevectorlayerdirector.sip
Expand Up @@ -16,11 +16,11 @@ class QgsLineVectorLayerDirector : QgsGraphDirector
* from the end point to the start point) and bidirectional or two-way
* (one can move in any direction)
*/
enum RoadDirection
enum Direction
{
RoadDirect, //!< One-way direct
RoadReversed, //!< One-way reversed
RoadBidirectional, //!< Two-way
DirectionForward, //!< One-way direct
DirectionBackward, //!< One-way reversed
DirectionBoth, //!< Two-way
};

/**
Expand All @@ -37,7 +37,7 @@ class QgsLineVectorLayerDirector : QgsGraphDirector
const QString& directDirectionValue,
const QString& reverseDirectionValue,
const QString& bothDirectionValue,
const RoadDirection defaultDirection
const Direction defaultDirection
);

//! Destructor
Expand Down
20 changes: 10 additions & 10 deletions src/analysis/network/qgslinevectorlayerdirector.cpp
Expand Up @@ -102,12 +102,12 @@ bool TiePointInfoCompare( const TiePointInfo& a, const TiePointInfo& b )
return a.mFirstPoint.x() == b.mFirstPoint.x() ? a.mFirstPoint.y() < b.mFirstPoint.y() : a.mFirstPoint.x() < b.mFirstPoint.x();
}

QgsLineVectorLayerDirector::QgsLineVectorLayerDirector(QgsVectorLayer *myLayer,
QgsLineVectorLayerDirector::QgsLineVectorLayerDirector( QgsVectorLayer *myLayer,
int directionFieldId,
const QString& directDirectionValue,
const QString& reverseDirectionValue,
const QString& bothDirectionValue,
const RoadDirection defaultDirection
const Direction defaultDirection
)
{
mVectorLayer = myLayer;
Expand Down Expand Up @@ -284,21 +284,21 @@ void QgsLineVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, c
fit = vl->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( la ) );
while ( fit.nextFeature( feature ) )
{
RoadDirection directionType = mDefaultDirection;
Direction directionType = mDefaultDirection;

// What direction have feature?
QString str = feature.attribute( mDirectionFieldId ).toString();
if ( str == mBothDirectionValue )
{
directionType = RoadDirection::RoadBidirectional;
directionType = Direction::DirectionBoth;
}
else if ( str == mDirectDirectionValue )
{
directionType = RoadDirection::RoadDirect;
directionType = Direction::DirectionForward;
}
else if ( str == mReverseDirectionValue )
{
directionType = RoadDirection::RoadReversed;
directionType = Direction::DirectionBackward;
}

// begin features segments and add arc to the Graph;
Expand Down Expand Up @@ -372,13 +372,13 @@ void QgsLineVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, c
prop.push_back(( *it )->cost( distance, feature ) );
}

if ( directionType == RoadDirection::RoadDirect ||
directionType == RoadDirection::RoadBidirectional )
if ( directionType == Direction::DirectionForward ||
directionType == Direction::DirectionBoth )
{
builder->addEdge( pt1idx, pt1, pt2idx, pt2, prop );
}
if ( directionType == RoadDirection::RoadReversed ||
directionType == RoadDirection::RoadBidirectional )
if ( directionType == Direction::DirectionBackward ||
directionType == Direction::DirectionBoth )
{
builder->addEdge( pt2idx, pt2, pt1idx, pt1, prop );
}
Expand Down
17 changes: 6 additions & 11 deletions src/analysis/network/qgslinevectorlayerdirector.h
Expand Up @@ -38,11 +38,11 @@ class ANALYSIS_EXPORT QgsLineVectorLayerDirector : public QgsGraphDirector
* from the end point to the start point) and bidirectional or two-way
* (one can move in any direction)
*/
enum RoadDirection
enum Direction
{
RoadDirect, //!< One-way direct
RoadReversed, //!< One-way reversed
RoadBidirectional, //!< Two-way
DirectionForward, //!< One-way direct
DirectionBackward, //!< One-way reversed
DirectionBoth, //!< Two-way
};

/**
Expand All @@ -60,7 +60,7 @@ class ANALYSIS_EXPORT QgsLineVectorLayerDirector : public QgsGraphDirector
const QString& directDirectionValue,
const QString& reverseDirectionValue,
const QString& bothDirectionValue,
const RoadDirection defaultDirection
const Direction defaultDirection
);

//! Destructor
Expand All @@ -77,16 +77,11 @@ class ANALYSIS_EXPORT QgsLineVectorLayerDirector : public QgsGraphDirector

private:
QgsVectorLayer *mVectorLayer;

int mDirectionFieldId;

QString mDirectDirectionValue;

QString mReverseDirectionValue;

QString mBothDirectionValue;

RoadDirection mDefaultDirection;
Direction mDefaultDirection;
};

#endif // QGSLINEVECTORLAYERDIRECTOR_H
4 changes: 2 additions & 2 deletions src/analysis/network/qgsnetworkspeedstrategy.h
Expand Up @@ -19,9 +19,9 @@
#include <qgsnetworkstrategy.h>

/** \ingroup analysis
* \class QgsSpeedStrategy
* \class QgsNetworkSpeedStrategy
* \note added in QGIS 3.0
* \brief Strategy for caclucating edge cost based on travel time. Should be
* \brief Strategy for calcucating edge cost based on travel time. Should be
* used for finding fastest path between two points.
*/
class ANALYSIS_EXPORT QgsNetworkSpeedStrategy : public QgsNetworkStrategy
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/roadgraph/linevectorlayersettings.cpp
Expand Up @@ -29,7 +29,7 @@
//standard includes

RgLineVectorLayerSettings::RgLineVectorLayerSettings()
: mDefaultDirection( QgsLineVectorLayerDirector::RoadDirection::RoadBidirectional )
: mDefaultDirection( QgsLineVectorLayerDirector::Direction::DirectionBoth )
, mDefaultSpeed( 40 )
{
}
Expand Down Expand Up @@ -58,7 +58,7 @@ bool RgLineVectorLayerSettings::test()

void RgLineVectorLayerSettings::read( const QgsProject *project )
{
mDefaultDirection = static_cast<QgsLineVectorLayerDirector::RoadDirection> ( project->readNumEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/defaultDirection" ) ) );
mDefaultDirection = static_cast<QgsLineVectorLayerDirector::Direction>( project->readNumEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/defaultDirection" ) ) );
mDirection = project->readEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/directionField" ) );
mFirstPointToLastPointDirectionVal =
project->readEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/FirstPointToLastPointDirectionVal" ) );
Expand Down Expand Up @@ -105,15 +105,15 @@ void RgLineVectorLayerSettings::setFromGui( QWidget *myGui )

if ( w->mcbDirectionDefault->currentIndex() == 0 )
{
mDefaultDirection = QgsLineVectorLayerDirector::RoadDirection::RoadBidirectional;
mDefaultDirection = QgsLineVectorLayerDirector::Direction::DirectionBoth;
}
else if ( w->mcbDirectionDefault->currentIndex() == 1 )
{
mDefaultDirection = QgsLineVectorLayerDirector::RoadDirection::RoadDirect;
mDefaultDirection = QgsLineVectorLayerDirector::Direction::DirectionForward;
}
else if ( w->mcbDirectionDefault->currentIndex() == 2 )
{
mDefaultDirection = QgsLineVectorLayerDirector::RoadDirection::RoadReversed;
mDefaultDirection = QgsLineVectorLayerDirector::Direction::DirectionBackward;
}

mSpeed = w->mcbSpeed->currentText();
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/roadgraph/linevectorlayersettings.h
Expand Up @@ -95,7 +95,7 @@ class RgLineVectorLayerSettings: public RgSettings
/**
* contained Default direction
*/
QgsLineVectorLayerDirector::RoadDirection mDefaultDirection;
QgsLineVectorLayerDirector::Direction mDefaultDirection;

/**
* contained speed filed name
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/roadgraph/linevectorlayerwidget.cpp
Expand Up @@ -143,13 +143,13 @@ RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget( RgLineVectorLa

switch ( s->mDefaultDirection )
{
case QgsLineVectorLayerDirector::RoadDirection::RoadBidirectional:
case QgsLineVectorLayerDirector::Direction::DirectionBoth:
mcbDirectionDefault->setCurrentIndex( 0 );
break;
case QgsLineVectorLayerDirector::RoadDirection::RoadDirect:
case QgsLineVectorLayerDirector::Direction::DirectionForward:
mcbDirectionDefault->setCurrentIndex( 1 );
break;
case QgsLineVectorLayerDirector::RoadDirection::RoadReversed:
case QgsLineVectorLayerDirector::Direction::DirectionBackward:
mcbDirectionDefault->setCurrentIndex( 2 );
break;
}
Expand Down

0 comments on commit d657c77

Please sign in to comment.