Skip to content
Permalink
Browse files
fix windows build after 37b3eaa
  • Loading branch information
jef-n committed Nov 13, 2021
1 parent 1021cf7 commit a6d4f92359338140c1b16972ec905f58a92902ec
Showing with 58 additions and 24 deletions.
  1. +23 −12 python/analysis/auto_generated/network/qgsgraph.sip.in
  2. +12 −0 src/analysis/network/qgsgraph.cpp
  3. +23 −12 src/analysis/network/qgsgraph.h
@@ -11,6 +11,7 @@




class QgsGraphEdge
{
%Docstring(signature="appended")
@@ -149,10 +150,9 @@ Returns the vertex at the given index.
:raises IndexError: if the vertex is not found.
%End
%MethodCode
auto it = sipCpp->mGraphVertices.constFind( a0 );
if ( it != sipCpp->mGraphVertices.constEnd() )
if ( sipCpp->hasVertex( a0 ) )
{
return sipConvertFromNewType( new QgsGraphVertex( ( it ).value() ), sipType_QgsGraphVertex, Py_None );
return sipConvertFromNewType( new QgsGraphVertex( sipCpp->vertex( a0 ) ), sipType_QgsGraphVertex, Py_None );
}
else
{
@@ -173,8 +173,7 @@ All edges which are incoming or outgoing edges for the vertex will also be remov
.. versionadded:: 3.24
%End
%MethodCode
auto it = sipCpp->mGraphVertices.constFind( a0 );
if ( it != sipCpp->mGraphVertices.constEnd() )
if ( sipCpp->hasVertex( a0 ) )
{
sipCpp->removeVertex( a0 );
}
@@ -198,10 +197,9 @@ Returns the edge at the given index.
:raises IndexError: if the edge is not found.
%End
%MethodCode
auto it = sipCpp->mGraphEdges.constFind( a0 );
if ( it != sipCpp->mGraphEdges.constEnd() )
if ( sipCpp->hasEdge( a0 ) )
{
return sipConvertFromNewType( new QgsGraphEdge( ( it ).value() ), sipType_QgsGraphEdge, Py_None );
return sipConvertFromNewType( new QgsGraphEdge( sipCpp->edge( a0 ) ), sipType_QgsGraphEdge, Py_None );
}
else
{
@@ -224,8 +222,7 @@ no longer have any incoming or outgoing edges as a result will be removed from t
.. versionadded:: 3.24
%End
%MethodCode
auto it = sipCpp->mGraphEdges.constFind( a0 );
if ( it != sipCpp->mGraphEdges.constEnd() )
if ( sipCpp->hasEdge( a0 ) )
{
sipCpp->removeEdge( a0 );
}
@@ -259,8 +256,7 @@ Returns -1 if no opposite edge exists.
.. versionadded:: 3.24
%End
%MethodCode
auto it = sipCpp->mGraphEdges.constFind( a0 );
if ( it != sipCpp->mGraphEdges.constEnd() )
if ( sipCpp->hasEdge( a0 ) )
{
sipRes = sipCpp->findOppositeEdge( a0 );
}
@@ -271,9 +267,24 @@ Returns -1 if no opposite edge exists.
}
%End

bool hasEdge( int index ) const;
%Docstring
Returns whether the edge of the given index exists.

.. versionadded:: 3.24
%End

bool hasVertex( int index ) const;
%Docstring
Returns whether the vertex of the given index exists.

.. versionadded:: 3.24
%End

protected:



};

/************************************************************************
@@ -135,6 +135,18 @@ int QgsGraph::findVertex( const QgsPointXY &pt ) const
return -1;
}

bool QgsGraph::hasVertex( int index ) const
{
auto it = mGraphVertices.constFind( index );
return it != mGraphVertices.constEnd();
}

bool QgsGraph::hasEdge( int index ) const
{
auto it = mGraphEdges.constFind( index );
return it != mGraphEdges.constEnd();
}

int QgsGraph::findOppositeEdge( int index ) const
{
auto it = mGraphEdges.constFind( index );
@@ -34,6 +34,7 @@

class QgsGraphVertex;


/**
* \ingroup analysis
* \class QgsGraphEdge
@@ -180,10 +181,9 @@ class ANALYSIS_EXPORT QgsGraph
*/
QgsGraphVertex vertex( int idx ) const;
% MethodCode
auto it = sipCpp->mGraphVertices.constFind( a0 );
if ( it != sipCpp->mGraphVertices.constEnd() )
if ( sipCpp->hasVertex( a0 ) )
{
return sipConvertFromNewType( new QgsGraphVertex( ( it ).value() ), sipType_QgsGraphVertex, Py_None );
return sipConvertFromNewType( new QgsGraphVertex( sipCpp->vertex( a0 ) ), sipType_QgsGraphVertex, Py_None );
}
else
{
@@ -215,8 +215,7 @@ class ANALYSIS_EXPORT QgsGraph
*/
void removeVertex( int index );
% MethodCode
auto it = sipCpp->mGraphVertices.constFind( a0 );
if ( it != sipCpp->mGraphVertices.constEnd() )
if ( sipCpp->hasVertex( a0 ) )
{
sipCpp->removeVertex( a0 );
}
@@ -248,10 +247,9 @@ class ANALYSIS_EXPORT QgsGraph
*/
QgsGraphEdge edge( int idx ) const;
% MethodCode
auto it = sipCpp->mGraphEdges.constFind( a0 );
if ( it != sipCpp->mGraphEdges.constEnd() )
if ( sipCpp->hasEdge( a0 ) )
{
return sipConvertFromNewType( new QgsGraphEdge( ( it ).value() ), sipType_QgsGraphEdge, Py_None );
return sipConvertFromNewType( new QgsGraphEdge( sipCpp->edge( a0 ) ), sipType_QgsGraphEdge, Py_None );
}
else
{
@@ -286,8 +284,7 @@ class ANALYSIS_EXPORT QgsGraph
*/
void removeEdge( int index );
% MethodCode
auto it = sipCpp->mGraphEdges.constFind( a0 );
if ( it != sipCpp->mGraphEdges.constEnd() )
if ( sipCpp->hasEdge( a0 ) )
{
sipCpp->removeEdge( a0 );
}
@@ -336,8 +333,7 @@ class ANALYSIS_EXPORT QgsGraph
*/
int findOppositeEdge( int index ) const;
% MethodCode
auto it = sipCpp->mGraphEdges.constFind( a0 );
if ( it != sipCpp->mGraphEdges.constEnd() )
if ( sipCpp->hasEdge( a0 ) )
{
sipRes = sipCpp->findOppositeEdge( a0 );
}
@@ -349,6 +345,20 @@ class ANALYSIS_EXPORT QgsGraph
% End
#endif

/**
* Returns whether the edge of the given index exists.
*
* \since QGIS 3.24
*/
bool hasEdge( int index ) const;

/**
* Returns whether the vertex of the given index exists.
*
* \since QGIS 3.24
*/
bool hasVertex( int index ) const;

protected:

#ifndef SIP_RUN
@@ -359,6 +369,7 @@ class ANALYSIS_EXPORT QgsGraph
QHash<int, QgsGraphEdge> mGraphEdges;
#endif


private:

int mNextVertexId = 0;

0 comments on commit a6d4f92

Please sign in to comment.