Skip to content
Permalink
Browse files

indentation update - please use prepare-commit.sh

  • Loading branch information
jef-n committed Sep 30, 2011
1 parent ee19294 commit b53e6229e37a65d7a010dd5c4190577183b22eb6
@@ -26,8 +26,8 @@
/**
* \ingroup networkanalysis
* \class QgsEdgeProperter
* \brief QgsEdgeProperter is a strategy pattern.
* You can use it for customize arc property. For example look at QgsDistanceArcProperter or src/plugins/roadgraph/speedproperter.h
* \brief QgsEdgeProperter is a strategy pattern.
* You can use it for customize arc property. For example look at QgsDistanceArcProperter or src/plugins/roadgraph/speedproperter.h
*/
class ANALYSIS_EXPORT QgsArcProperter
{
@@ -37,14 +37,14 @@ class ANALYSIS_EXPORT QgsArcProperter
*/
QgsArcProperter()
{ }

/**
* QgsGraphDirector call this method for fetching attribute from source layer
* \return required attributes list
*/
virtual QgsAttributeList requiredAttributes() const
{ return QgsAttributeList(); }

/**
* calculate and return adge property
*/
@@ -14,5 +14,5 @@

QVariant QgsDistanceArcProperter::property( double distance, const QgsFeature& f ) const
{
return QVariant( distance );
return QVariant( distance );
}
@@ -29,7 +29,7 @@ QgsGraph::~QgsGraph()
int QgsGraph::addVertex( const QgsPoint& pt )
{
mGraphVertexes.append( QgsGraphVertex( pt ) );
return mGraphVertexes.size()-1;
return mGraphVertexes.size() - 1;
}

int QgsGraph::addArc( int outVertexIdx, int inVertexIdx, const QVector< QVariant >& properties )
@@ -40,12 +40,12 @@ int QgsGraph::addArc( int outVertexIdx, int inVertexIdx, const QVector< QVariant
e.mOut = outVertexIdx;
e.mIn = inVertexIdx;
mGraphArc.push_back( e );
int edgeIdx = mGraphArc.size()-1;
int edgeIdx = mGraphArc.size() - 1;

mGraphVertexes[ outVertexIdx ].mOutArc.push_back( edgeIdx );
mGraphVertexes[ inVertexIdx ].mInArc.push_back( edgeIdx );
return mGraphArc.size()-1;

return mGraphArc.size() - 1;
}

const QgsGraphVertex& QgsGraph::vertex( int idx ) const
@@ -84,10 +84,10 @@ int QgsGraph::findVertex( const QgsPoint& pt ) const

QgsGraphArc::QgsGraphArc()
{

}

QVariant QgsGraphArc::property(int i) const
QVariant QgsGraphArc::property( int i ) const
{
return mProperties[ i ];
}
@@ -118,7 +118,7 @@ int QgsGraphArc::out() const
}

QgsGraphVertex::QgsGraphVertex( const QgsPoint& point )
: mCoordinate( point )
: mCoordinate( point )
{

}
@@ -14,10 +14,10 @@
***************************************************************************/

/*
*
*
* \file qgsgraph.h
* Этот файл описывает встроенные в QGIS классы описывающие математический граф. Вершина графа идентифицируется своими географическими координатами, никакие дополнительные свойства ей не могут быть присвоены. Количество свойств графа определяется разработчиком и не ограничено, например длина и время движения по дуге. Граф может быть направленным, иметь инцедентные ребра и петли.
*
*
*/

#ifndef QGSGRAPHH
@@ -48,7 +48,7 @@ class ANALYSIS_EXPORT QgsGraphArc
* @param propertyIndex property index
*/
QVariant property( int propertyIndex ) const;

/**
* get array of proertyes
*/
@@ -73,7 +73,7 @@ class ANALYSIS_EXPORT QgsGraphArc
int mOut;
int mIn;

friend class QgsGraph;
friend class QgsGraph;
};


@@ -97,28 +97,28 @@ class ANALYSIS_EXPORT QgsGraphVertex
*/

QgsGraphVertex( const QgsPoint& point );

/**
* return outgoing edges
*/
QgsGraphArcIdList outArc() const;

/**
* return incoming edges
*/
QgsGraphArcIdList inArc() const;

/**
* return vertex point
*/
QgsPoint point() const;

private:
QgsPoint mCoordinate;
QgsGraphArcIdList mOutArc;
QgsGraphArcIdList mInArc;

friend class QgsGraph;
friend class QgsGraph;
};

/**
@@ -139,28 +139,28 @@ class ANALYSIS_EXPORT QgsGraph
* add vertex to a grap
*/
int addVertex( const QgsPoint& pt );

/**
* add edge to a graph
*/
int addArc( int outVertexIdx, int inVertexIdx, const QVector< QVariant >& properties );

/**
* retrun vertex count
*/
int vertexCount() const;

/**
* return vertex at index
*/
const QgsGraphVertex& vertex( int idx ) const;

/**
* retrun edge count
*/
/**
* retrun edge count
*/
int arcCount() const;
/**

/**
* retrun edge at index
*/
const QgsGraphArc& arc( int idx ) const;
@@ -171,9 +171,9 @@ class ANALYSIS_EXPORT QgsGraph
*/
int findVertex( const QgsPoint& pt ) const;

private:
private:
QVector<QgsGraphVertex> mGraphVertexes;

QVector<QgsGraphArc> mGraphArc;
};

@@ -28,25 +28,25 @@

void QgsGraphAnalyzer::shortestpath( const QgsGraph* source, int startPointIdx, int criterionNum, const QVector<int>& destPointCost, QVector<double>& cost, QgsGraph* treeResult )
{

// QMap< cost, vertexIdx > not_begin
// I use it and not create any struct or class.
QMap< double, int > not_begin;
QMap< double, int > not_begin;
QMap< double, int >::iterator it;

// QVector< QPair< cost, arc id > result
QVector< QPair< double, int > > result;

result.reserve( source->vertexCount() );
int i;
for ( i=0; i < source->vertexCount(); ++i )
for ( i = 0; i < source->vertexCount(); ++i )
{
result.push_back( QPair<double, int> ( std::numeric_limits<double>::infinity() , i ) );
}
result[ startPointIdx ] = QPair<double, int> ( 0.0, -1 );

not_begin.insert( 0.0, startPointIdx );

// begin Dijkstra algorithm
while ( !not_begin.empty() )
{
@@ -63,47 +63,47 @@ void QgsGraphAnalyzer::shortestpath( const QgsGraph* source, int startPointIdx,
const QgsGraphArc& arc = source->arc( *arcIt );
double cost = arc.property( criterionNum ).toDouble() + curCost;

if ( cost < result[ arc.in() ].first )
if ( cost < result[ arc.in()].first )
{
result[ arc.in() ] = QPair< double, int >( cost, *arcIt );
result[ arc.in()] = QPair< double, int >( cost, *arcIt );
not_begin.insert( cost, arc.in() );
}
}
}

// fill shortestpath tree
if ( treeResult != NULL )
{
// sourceVertexIdx2resultVertexIdx
QVector<int> source2result( result.size(), -1 );

for ( i=0; i < source->vertexCount(); ++i )
for ( i = 0; i < source->vertexCount(); ++i )
{
if ( result[ i ].first < std::numeric_limits<double>::infinity() )
{
source2result[ i ] = treeResult->addVertex( source->vertex(i).point() );
source2result[ i ] = treeResult->addVertex( source->vertex( i ).point() );
}
}
for ( i=0; i < source->vertexCount(); ++i )
for ( i = 0; i < source->vertexCount(); ++i )
{
if ( result[ i ].first < std::numeric_limits<double>::infinity() && result[i].second != -1)
{
if ( result[ i ].first < std::numeric_limits<double>::infinity() && result[i].second != -1 )
{
const QgsGraphArc& arc = source->arc( result[i].second );

treeResult->addArc( source2result[ arc.out() ], source2result[ i ],
arc.properties() );
treeResult->addArc( source2result[ arc.out()], source2result[ i ],
arc.properties() );
}
}
}

// fill shortestpath's costs
for ( i=0; i < destPointCost.size(); ++i )
for ( i = 0; i < destPointCost.size(); ++i )
{
cost[i] = result[ destPointCost[i] ].first;
}
}

QgsGraph* QgsGraphAnalyzer::shortestTree( const QgsGraph* source, int startVertexIdx, int criterionNum)
QgsGraph* QgsGraphAnalyzer::shortestTree( const QgsGraph* source, int startVertexIdx, int criterionNum )
{
QgsGraph *g = new QgsGraph;
QVector<int> v;
@@ -40,7 +40,7 @@ class ANALYSIS_EXPORT QgsGraphBuilder : public QgsGraphBuilderInterface
* default constructor
*/
QgsGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool otfEnabled = true, double topologyTolerance = 0.0, const QString& ellipsoidID = "WGS84" );

~QgsGraphBuilder();

/*
@@ -54,8 +54,8 @@ class ANALYSIS_EXPORT QgsGraphBuilder : public QgsGraphBuilderInterface
* return QgsGraph result;
*/
QgsGraph* graph();
private:

private:

QgsGraph *mGraph;
};
@@ -37,13 +37,13 @@ class ANALYSIS_EXPORT QgsGraphBuilderInterface
/**
* QgsGraphBuilderInterface constructor
* @param crs Coordinate reference system for new graph vertex
* @param ctfEnabled enable coordinate transform from source graph CRS to CRS graph
* @param ctfEnabled enable coordinate transform from source graph CRS to CRS graph
* @param topologyTolerance sqrt distance between source point as one graph vertex
* @param ellipsoidID ellipsoid for edge measurement
*/
*/
QgsGraphBuilderInterface( const QgsCoordinateReferenceSystem& crs, bool ctfEnabled = true, double topologyTolerance = 0.0, const QString& ellipsoidID = "WGS84" ) :
mCrs( crs ), mCtfEnabled ( ctfEnabled ), mTopologyTolerance( topologyTolerance )
{
mCrs( crs ), mCtfEnabled( ctfEnabled ), mTopologyTolerance( topologyTolerance )
{
mDa.setSourceCrs( mCrs.srsid() );
mDa.setEllipsoid( ellipsoidID );
mDa.setProjectionsEnabled( ctfEnabled );
@@ -58,7 +58,7 @@ class ANALYSIS_EXPORT QgsGraphBuilderInterface
{
return mCrs;
}

//! get coordinate transformation enabled
bool coordinateTransformationEnabled()
{
@@ -70,7 +70,7 @@ class ANALYSIS_EXPORT QgsGraphBuilderInterface
{
return mTopologyTolerance;
}

//! get measurement tool
QgsDistanceArea* distanceArea()
{
@@ -97,7 +97,7 @@ class ANALYSIS_EXPORT QgsGraphBuilderInterface
*/
virtual void addArc( int pt1id, const QgsPoint& pt1, int pt2id, const QgsPoint& pt2, const QVector< QVariant >& properties )
{ }

private:
QgsCoordinateReferenceSystem mCrs;

@@ -59,17 +59,17 @@ class ANALYSIS_EXPORT QgsGraphDirector : public QObject
const QVector< QgsPoint >& additionalPoints,
QVector< QgsPoint>& tiedPoints ) const
{}

void addProperter( QgsArcProperter* prop )
{
mProperterList.push_back( prop );
}

/**
* return Director name
*/
virtual QString name() const = 0;

protected:
QList<QgsArcProperter*> mProperterList;
};

0 comments on commit b53e622

Please sign in to comment.
You can’t perform that action at this time.