Skip to content

Commit

Permalink
[API] rename QgsArcProperter to QgsStrategy
Browse files Browse the repository at this point in the history
Also update subclasses names and do some more refactoring.
  • Loading branch information
alexbruy committed Nov 21, 2016
1 parent 137b198 commit 5992f74
Show file tree
Hide file tree
Showing 33 changed files with 381 additions and 443 deletions.
8 changes: 4 additions & 4 deletions python/analysis/analysis.sip
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
%Include raster/qgstotalcurvaturefilter.sip

%Include network/qgsgraph.sip
%Include network/qgsarcproperter.sip
%Include network/qgsspeedarcproperter.sip
%Include network/qgsdistancearcproperter.sip
%Include network/qgsgraphbuilderintr.sip
%Include network/qgsstrategy.sip
%Include network/qgsspeedstrategy.sip
%Include network/qgsdistancestrategy.sip
%Include network/qgsgraphbuilderinterface.sip
%Include network/qgsgraphbuilder.sip
%Include network/qgsgraphdirector.sip
%Include network/qgslinevectorlayerdirector.sip
Expand Down
45 changes: 0 additions & 45 deletions python/analysis/network/qgsarcproperter.sip

This file was deleted.

9 changes: 0 additions & 9 deletions python/analysis/network/qgsdistancearcproperter.sip

This file was deleted.

9 changes: 9 additions & 0 deletions python/analysis/network/qgsdistancestrategy.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class QgsDistanceStrategy : QgsStrategy
{
%TypeHeaderCode
#include <qgsdistancestrategy.h>
%End

public:
virtual QVariant cost( double distance, const QgsFeature& ) const;
};
57 changes: 29 additions & 28 deletions python/analysis/network/qgsgraph.sip
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
/**
* \ingroup analysis
* \class QgsGraphArc
* \class QgsGraphEdge
* \brief This class implements a graph edge
*/
class QgsGraphArc
class QgsGraphEdge
{
%TypeHeaderCode
#include <qgsgraph.h>
%End

public:
QgsGraphArc();
QgsGraphEdge();

/**
* return property value
* @param propertyIndex property index
* Returns edge cost calculated using specified strategy
* @param strategyIndex strategy index
*/
QVariant property( int propertyIndex ) const;
QVariant cost( int strategyIndex ) const;

/**
* get array of properties
* Returns array of available strategies
*/
QVector< QVariant > properties() const;
QVector< QVariant > strategies() const;

/**
* return index of outgoing vertex
* Returns index of the outgoing vertex
*/
int outVertex() const;

/**
* return index of incoming vertex
* Returns index of the incoming vertex
*/
int inVertex() const;
};


typedef QList< int > QgsGraphArcIdList;
typedef QList< int > QgsGraphEdgeIds;

/**
* \ingroup analysis
Expand All @@ -50,7 +50,7 @@ class QgsGraphVertex

public:
/**
* default constructor. It need for QT's container, e.g. QVector
* Default constructor. It is needed for Qt's container, e.g. QVector
*/
QgsGraphVertex();

Expand All @@ -61,17 +61,17 @@ class QgsGraphVertex
QgsGraphVertex( const QgsPoint& point );

/**
* return outgoing edges
* Returns outgoing edges ids
*/
QgsGraphArcIdList outArc() const;
QgsGraphEdgeIds outEdges() const;

/**
* return incoming edges
* Return incoming edges ids
*/
QgsGraphArcIdList inArc() const;
QgsGraphEdgeIds inEdges() const;

/**
* return vertex point
* Returns point associated with graph vertex
*/
QgsPoint point() const;
};
Expand All @@ -91,39 +91,40 @@ class QgsGraph
public:
QgsGraph();

// begin graph constructing methods
// Graph constructing methods

/**
* add vertex to a grap
* Add a vertex to the graph
*/
int addVertex( const QgsPoint& pt );

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

/**
* return vertex count
* Returns number of graph vertices
*/
int vertexCount() const;

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

/**
* return edge count
* Returns number of graph edges
*/
int arcCount() const;
int edgeCount() const;

/**
* return edge at index
* Returns edge at given index
*/
const QgsGraphArc& arc( int idx ) const;
const QgsGraphEdge& edge( int idx ) const;

/**
* find vertex by point
* Find vertex by associated point
* \return vertex index
*/
int findVertex( const QgsPoint& pt ) const;
Expand Down
6 changes: 3 additions & 3 deletions python/analysis/network/qgsgraphbuilder.sip
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class QgsGraphBuilder : QgsGraphBuilderInterface

public:
/**
* default constructor
* Default constructor
*/
QgsGraphBuilder( const QgsCoordinateReferenceSystem& crs, bool otfEnabled = true, double topologyTolerance = 0.0, const QString& ellipsoidID = "WGS84" );

Expand All @@ -23,10 +23,10 @@ class QgsGraphBuilder : QgsGraphBuilderInterface
*/
virtual void addVertex( int id, const QgsPoint& pt );

virtual void addArc( int pt1id, const QgsPoint& pt1, int pt2id, const QgsPoint& pt2, const QVector< QVariant >& prop );
virtual void addEdge( int pt1id, const QgsPoint& pt1, int pt2id, const QgsPoint& pt2, const QVector< QVariant >& prop );

/**
* return QgsGraph result;
* Returns generated QgsGraph
*/
QgsGraph* graph() /Factory/;
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class QgsGraphBuilderInterface
{
%TypeHeaderCode
#include <qgsgraphbuilderintr.h>
#include <qgsgraphbuilderinterface.h>
%End

%ConvertToSubClassCode
Expand All @@ -22,42 +22,45 @@ class QgsGraphBuilderInterface

public:
/**
* QgsGraphBuilderInterface constructor
* Default constructor
* @param crs Coordinate reference system for new graph vertex
* @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" );

//! Destructor
virtual ~QgsGraphBuilderInterface();

//! Returns destinaltion CRS
QgsCoordinateReferenceSystem destinationCrs() const;

//! get coordinate transformation enabled
//! Returns coordinate transformation enabled
bool coordinateTransformationEnabled();

//! get topology tolerance
//! Returns topology tolerance
double topologyTolerance();

//! get measurement tool
//! Returns measurement tool
QgsDistanceArea* distanceArea();

/**
* add vertex
* Add vertex to the graph
* @param id vertex identifier
* @param pt vertex coordinate
* @param pt vertex coordinates
* @note id and pt are redundant. You can use pt or id to identify the vertex
*/
virtual void addVertex( int id, const QgsPoint &pt );

/**
* add arc
* Add edge to the graph
* @param pt1id first vertex identificator
* @param pt1 first vertex coordinate
* @param pt1 first vertex coordinates
* @param pt2id second vertex identificator
* @param pt2 second vertex coordinate
* @param properties arc properties
* @param pt2 second vertex coordinates
* @param strategies optimization strategies
* @note pt1id, pt1 and pt2id, pt2 is a redundant interface. You can use vertex coordinates or their identificators.
*/
virtual void addArc( int pt1id, const QgsPoint& pt1, int pt2id, const QgsPoint& pt2, const QVector< QVariant >& properties );

virtual void addEdge( int pt1id, const QgsPoint& pt1, int pt2id, const QgsPoint& pt2, const QVector< QVariant >& strategies );
};
22 changes: 9 additions & 13 deletions python/analysis/network/qgsgraphdirector.sip
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,21 @@ class QgsGraphDirector : QObject
virtual ~QgsGraphDirector();

/**
* Make a graph using RgGraphBuilder
* Make a graph using QgsGraphBuilder
*
* @param builder The graph builder
*
* @param additionalPoints Vector of points that must be tied to the graph
*
* @param tiedPoints Vector of tied points
*
* @note if tiedPoints[i]==QgsPoint(0.0,0.0) then tied failed.
* @param builder the graph builder
* @param additionalPoints list of points that should be snapped to the graph
* @param tiedPoints list of snapped points
* @note if tiedPoints[i] == QgsPoint(0.0,0.0) then snapping failed.
*/
virtual void makeGraph( QgsGraphBuilderInterface *builder,
const QVector< QgsPoint > &additionalPoints,
QVector< QgsPoint> &tiedPoints /Out/ );
QVector< QgsPoint > &snappedPoints /Out/ ) const;

void addProperter( QgsArcProperter* prop /Transfer/ );
//! Add optimization strategy
void addStrategy( QgsStrategy* prop /Transfer/);

/**
* return Director name
*/
//! Returns director name
virtual QString name() const = 0;
};

2 changes: 1 addition & 1 deletion python/analysis/network/qgslinevectorlayerdirector.sip
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class QgsLineVectorLayerDirector : QgsGraphDirector
*/
void makeGraph( QgsGraphBuilderInterface *builder,
const QVector< QgsPoint >& additionalPoints,
QVector< QgsPoint>& tiedPoints /Out/ ) const;
QVector< QgsPoint>& snappedPoints /Out/ ) const;

QString name() const;
};
Expand Down
13 changes: 0 additions & 13 deletions python/analysis/network/qgsspeedarcproperter.sip

This file was deleted.

13 changes: 13 additions & 0 deletions python/analysis/network/qgsspeedstrategy.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class QgsSpeedStrategy : QgsStrategy
{
%TypeHeaderCode
#include <qgsspeedstrategy.h>
%End

public:
QgsSpeedStrategy( int attributeId, double defaultValue, double toMetricFactor );

QVariant cost( double distance, const QgsFeature& f ) const;

QgsAttributeList requiredAttributes() const;
};
Loading

0 comments on commit 5992f74

Please sign in to comment.