Skip to content
Permalink
Browse files

[API] rename QgsArcProperter to QgsStrategy

Also update subclasses names and do some more refactoring.
  • Loading branch information
alexbruy committed Nov 21, 2016
1 parent 137b198 commit 5992f74e04eead414da2ea682e22c4ecf4008c47
Showing with 381 additions and 443 deletions.
  1. +4 −4 python/analysis/analysis.sip
  2. +0 −45 python/analysis/network/qgsarcproperter.sip
  3. +0 −9 python/analysis/network/qgsdistancearcproperter.sip
  4. +9 −0 python/analysis/network/qgsdistancestrategy.sip
  5. +29 −28 python/analysis/network/qgsgraph.sip
  6. +3 −3 python/analysis/network/qgsgraphbuilder.sip
  7. +16 −13 python/analysis/network/{qgsgraphbuilderintr.sip → qgsgraphbuilderinterface.sip}
  8. +9 −13 python/analysis/network/qgsgraphdirector.sip
  9. +1 −1 python/analysis/network/qgslinevectorlayerdirector.sip
  10. +0 −13 python/analysis/network/qgsspeedarcproperter.sip
  11. +13 −0 python/analysis/network/qgsspeedstrategy.sip
  12. +50 −0 python/analysis/network/qgsstrategy.sip
  13. +6 −6 src/analysis/CMakeLists.txt
  14. +3 −3 src/analysis/network/{qgsdistancearcproperter.cpp → qgsdistancestrategy.cpp}
  15. +9 −7 src/analysis/network/{qgsdistancearcproperter.h → qgsdistancestrategy.h}
  16. +37 −33 src/analysis/network/qgsgraph.cpp
  17. +37 −38 src/analysis/network/qgsgraph.h
  18. +20 −22 src/analysis/network/qgsgraphanalyzer.cpp
  19. +21 −22 src/analysis/network/qgsgraphanalyzer.h
  20. +3 −3 src/analysis/network/qgsgraphbuilder.cpp
  21. +5 −5 src/analysis/network/qgsgraphbuilder.h
  22. +17 −15 src/analysis/network/{qgsgraphbuilderintr.h → qgsgraphbuilderinterface.h}
  23. +13 −14 src/analysis/network/qgsgraphdirector.h
  24. +16 −16 src/analysis/network/qgslinevectorlayerdirector.cpp
  25. +6 −5 src/analysis/network/qgslinevectorlayerdirector.h
  26. +6 −6 src/analysis/network/{qgsspeedarcproperter.cpp → qgsspeedstrategy.cpp}
  27. +16 −15 src/analysis/network/{qgsspeedarcproperter.h → qgsspeedstrategy.h}
  28. +19 −15 src/analysis/network/{qgsarcproperter.h → qgsstrategy.h}
  29. +0 −1 src/plugins/roadgraph/CMakeLists.txt
  30. +5 −5 src/plugins/roadgraph/roadgraphplugin.cpp
  31. +8 −8 src/plugins/roadgraph/shortestpathwidget.cpp
  32. +0 −41 src/plugins/roadgraph/speedproperter.cpp
  33. +0 −34 src/plugins/roadgraph/speedproperter.h
@@ -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

This file was deleted.

This file was deleted.

@@ -0,0 +1,9 @@
class QgsDistanceStrategy : QgsStrategy
{
%TypeHeaderCode
#include <qgsdistancestrategy.h>
%End

public:
virtual QVariant cost( double distance, const QgsFeature& ) const;
};
@@ -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
@@ -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();

@@ -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;
};
@@ -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;
@@ -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" );

@@ -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/;
};
@@ -10,7 +10,7 @@
class QgsGraphBuilderInterface
{
%TypeHeaderCode
#include <qgsgraphbuilderintr.h>
#include <qgsgraphbuilderinterface.h>
%End

%ConvertToSubClassCode
@@ -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 );
};
@@ -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;
};

@@ -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;
};

This file was deleted.

@@ -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;
};

0 comments on commit 5992f74

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