Skip to content
Permalink
Browse files

[network analysis] use QgsFeatureSource instead of QgsVectorLayer in

QgsVectorLayerDirector
  • Loading branch information
alexbruy committed Jul 16, 2017
1 parent 23a4d60 commit 126a27425a773d60ed2d1bf345725971f9f0e556
@@ -361,8 +361,6 @@ Data Providers {#qgis_api_break_3_0_DataProviders}
- mAttrPalIndexName: overwrite palAttributeIndexNames()




Qgis {#qgis_api_break_3_0_Qgis}
----

@@ -1116,7 +1114,7 @@ version instead.
- QgsExpression::Node::referencedColumns() returns QSet<QString> instead of QStringList
- `QgsExpression::Node` was renamed to `QgsExpressionNode`
- `QgsExpression::Function` was renamed to `QgsExpressionFunction`
- variableHelpText() no longer returns a formatted HTML string. It now just returns the plain text help string. Use formatVariableHelp()
- variableHelpText() no longer returns a formatted HTML string. It now just returns the plain text help string. Use formatVariableHelp()
to obtain the formatted version.


@@ -2512,6 +2510,11 @@ QgsRendererAbstractMetadata {#qgis_api_break_3_0_QgsRendererAbstractMetadata}

- createRenderer() now expects a reference to QgsReadWriteContext as the second argument

QgsVectorLayerDirector {#qgis_api_break_3_0_QgsVectorLayerDirector}
----------------------

- QgsVectorLayerDirector() constructor now expects a reference to QgsFeatureSource as the first argument


Processing {#qgis_api_break_3_0_Processing}
----------
@@ -29,7 +29,7 @@ class QgsVectorLayerDirector : QgsGraphDirector
DirectionBoth,
};

QgsVectorLayerDirector( QgsVectorLayer *myLayer,
QgsVectorLayerDirector( QgsFeatureSource *source,
int directionFieldId,
const QString &directDirectionValue,
const QString &reverseDirectionValue,
@@ -38,7 +38,7 @@ class QgsVectorLayerDirector : QgsGraphDirector
);
%Docstring
Default constructor
\param myLayer source vector layer
\param source feature source representing network
\param directionFieldId field containing direction value
\param directDirectionValue value for direct one-way road
\param reverseDirectionValue value for reversed one-way road
@@ -22,12 +22,12 @@
#include "qgsgraphbuilderinterface.h"

#include "qgsfeatureiterator.h"
#include <qgsvectorlayer.h>
#include <qgsvectordataprovider.h>
#include <qgspoint.h>
#include <qgsgeometry.h>
#include <qgsdistancearea.h>
#include <qgswkbtypes.h>
#include "qgsfeaturesource.h"
#include "qgsvectordataprovider.h"
#include "qgspoint.h"
#include "qgsgeometry.h"
#include "qgsdistancearea.h"
#include 'qgswkbtypes.h"
#include <QString>
#include <QtAlgorithms>
@@ -102,15 +102,15 @@ bool TiePointInfoCompare( const TiePointInfo &a, const TiePointInfo &b )
return a.mFirstPoint.x() == b.mFirstPoint.x() ? a.mFirstPoint.y() < b.mFirstPoint.y() : a.mFirstPoint.x() < b.mFirstPoint.x();
}
QgsVectorLayerDirector::QgsVectorLayerDirector( QgsVectorLayer *myLayer,
QgsVectorLayerDirector::QgsVectorLayerDirector( QgsFeatureSource *source,
int directionFieldId,
const QString &directDirectionValue,
const QString &reverseDirectionValue,
const QString &bothDirectionValue,
const Direction defaultDirection
)
{
mVectorLayer = myLayer;
mSource = source;
mDirectionFieldId = directionFieldId;
mDirectDirectionValue = directDirectionValue;
mReverseDirectionValue = reverseDirectionValue;
@@ -126,23 +126,18 @@ QString QgsVectorLayerDirector::name() const
void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const QVector< QgsPointXY > &additionalPoints,
QVector< QgsPointXY > &snappedPoints ) const
{
QgsVectorLayer *vl = mVectorLayer;

if ( !vl )
return;

int featureCount = ( int ) vl->featureCount() * 2;
int featureCount = ( int ) mSource->featureCount() * 2;
int step = 0;
QgsCoordinateTransform ct;
ct.setSourceCrs( vl->crs() );
ct.setSourceCrs( mSource->sourceCrs() );
if ( builder->coordinateTransformationEnabled() )
{
ct.setDestinationCrs( builder->destinationCrs() );
}
else
{
ct.setDestinationCrs( vl->crs() );
ct.setDestinationCrs( mSource->sourceCrs() );
}
snappedPoints = QVector< QgsPointXY >( additionalPoints.size(), QgsPointXY( 0.0, 0.0 ) );
@@ -156,7 +151,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
//Graph's points;
QVector< QgsPointXY > points;
QgsFeatureIterator fit = vl->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() ) );
QgsFeatureIterator fit = mSource->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() ) );
// begin: tie points to the graph
QgsAttributeList la;
@@ -276,7 +271,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
} // end fill attribute list 'la'
// begin graph construction
fit = vl->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( la ) );
fit = mSource->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( la ) );
while ( fit.nextFeature( feature ) )
{
Direction directionType = mDefaultDirection;
@@ -388,5 +383,5 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
} // for (it = pl.begin(); it != pl.end(); ++it)
}
emit buildProgress( ++step, featureCount );
} // while( vl->nextFeature(feature) )
} // while( mSource->nextFeature(feature) )
} // makeGraph( QgsGraphBuilderInterface *builder, const QVector< QgsPointXY >& additionalPoints, QVector< QgsPointXY >& tiedPoint )
@@ -22,7 +22,7 @@
#include "qgis_analysis.h"

class QgsGraphBuilderInterface;
class QgsVectorLayer;
class QgsFeatureSource;

/**
* \ingroup analysis
@@ -51,15 +51,15 @@ class ANALYSIS_EXPORT QgsVectorLayerDirector : public QgsGraphDirector

/**
* Default constructor
* \param myLayer source vector layer
* \param source feature source representing network
* \param directionFieldId field containing direction value
* \param directDirectionValue value for direct one-way road
* \param reverseDirectionValue value for reversed one-way road
* \param bothDirectionValue value for two-way (bidirectional) road
* \param defaultDirection default direction. Will be used if corresponding
* attribute value is not set or does not equal to the given values
*/
QgsVectorLayerDirector( QgsVectorLayer *myLayer,
QgsVectorLayerDirector( QgsFeatureSource *source,
int directionFieldId,
const QString &directDirectionValue,
const QString &reverseDirectionValue,
@@ -79,7 +79,7 @@ class ANALYSIS_EXPORT QgsVectorLayerDirector : public QgsGraphDirector
QString name() const override;

private:
QgsVectorLayer *mVectorLayer = nullptr;
QgsFeatureSource *mSource = nullptr;
int mDirectionFieldId;
QString mDirectDirectionValue;
QString mReverseDirectionValue;

0 comments on commit 126a274

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