Skip to content

Commit

Permalink
fix windows build after 37b3eaa
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Nov 13, 2021
1 parent 1021cf7 commit a6d4f92
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 24 deletions.
35 changes: 23 additions & 12 deletions python/analysis/auto_generated/network/qgsgraph.sip.in
Expand Up @@ -11,6 +11,7 @@




class QgsGraphEdge
{
%Docstring(signature="appended")
Expand Down Expand Up @@ -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
{
Expand All @@ -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 );
}
Expand All @@ -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
{
Expand All @@ -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 );
}
Expand Down Expand Up @@ -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 );
}
Expand All @@ -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:



};

/************************************************************************
Expand Down
12 changes: 12 additions & 0 deletions src/analysis/network/qgsgraph.cpp
Expand Up @@ -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 );
Expand Down
35 changes: 23 additions & 12 deletions src/analysis/network/qgsgraph.h
Expand Up @@ -34,6 +34,7 @@

class QgsGraphVertex;


/**
* \ingroup analysis
* \class QgsGraphEdge
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 );
}
Expand All @@ -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
Expand All @@ -359,6 +369,7 @@ class ANALYSIS_EXPORT QgsGraph
QHash<int, QgsGraphEdge> mGraphEdges;
#endif


private:

int mNextVertexId = 0;
Expand Down

0 comments on commit a6d4f92

Please sign in to comment.