22
22
#include " qgsgraphbuilderinterface.h"
23
23
24
24
#include " qgsfeatureiterator.h"
25
- #include < qgsvectorlayer.h >
26
- #include < qgsvectordataprovider.h>
27
- #include < qgspoint.h>
28
- #include < qgsgeometry.h>
29
- #include < qgsdistancearea.h>
30
- #include < qgswkbtypes.h>
25
+ #include " qgsfeaturesource.h "
26
+ #include " qgsvectordataprovider.h"
27
+ #include " qgspoint.h"
28
+ #include " qgsgeometry.h"
29
+ #include " qgsdistancearea.h"
30
+ #include ' qgswkbtypes.h"
31
31
32
32
#include <QString>
33
33
#include <QtAlgorithms>
@@ -102,15 +102,15 @@ bool TiePointInfoCompare( const TiePointInfo &a, const TiePointInfo &b )
102
102
return a.mFirstPoint.x() == b.mFirstPoint.x() ? a.mFirstPoint.y() < b.mFirstPoint.y() : a.mFirstPoint.x() < b.mFirstPoint.x();
103
103
}
104
104
105
- QgsVectorLayerDirector::QgsVectorLayerDirector ( QgsVectorLayer *myLayer ,
105
+ QgsVectorLayerDirector::QgsVectorLayerDirector( QgsFeatureSource *source ,
106
106
int directionFieldId,
107
107
const QString &directDirectionValue,
108
108
const QString &reverseDirectionValue,
109
109
const QString &bothDirectionValue,
110
110
const Direction defaultDirection
111
111
)
112
112
{
113
- mVectorLayer = myLayer ;
113
+ mSource = source ;
114
114
mDirectionFieldId = directionFieldId;
115
115
mDirectDirectionValue = directDirectionValue;
116
116
mReverseDirectionValue = reverseDirectionValue;
@@ -126,23 +126,18 @@ QString QgsVectorLayerDirector::name() const
126
126
void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const QVector< QgsPointXY > &additionalPoints,
127
127
QVector< QgsPointXY > &snappedPoints ) const
128
128
{
129
- QgsVectorLayer *vl = mVectorLayer ;
130
-
131
- if ( !vl )
132
- return ;
133
-
134
- int featureCount = ( int ) vl->featureCount () * 2 ;
129
+ int featureCount = ( int ) mSource->featureCount() * 2;
135
130
int step = 0;
136
131
137
132
QgsCoordinateTransform ct;
138
- ct.setSourceCrs ( vl-> crs () );
133
+ ct.setSourceCrs( mSource->sourceCrs () );
139
134
if ( builder->coordinateTransformationEnabled() )
140
135
{
141
136
ct.setDestinationCrs( builder->destinationCrs() );
142
137
}
143
138
else
144
139
{
145
- ct.setDestinationCrs ( vl-> crs () );
140
+ ct.setDestinationCrs( mSource->sourceCrs () );
146
141
}
147
142
148
143
snappedPoints = QVector< QgsPointXY >( additionalPoints.size(), QgsPointXY( 0.0, 0.0 ) );
@@ -156,7 +151,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
156
151
//Graph's points;
157
152
QVector< QgsPointXY > points;
158
153
159
- QgsFeatureIterator fit = vl ->getFeatures ( QgsFeatureRequest ().setSubsetOfAttributes ( QgsAttributeList () ) );
154
+ QgsFeatureIterator fit = mSource ->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( QgsAttributeList() ) );
160
155
161
156
// begin: tie points to the graph
162
157
QgsAttributeList la;
@@ -276,7 +271,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
276
271
} // end fill attribute list 'la'
277
272
278
273
// begin graph construction
279
- fit = vl ->getFeatures ( QgsFeatureRequest ().setSubsetOfAttributes ( la ) );
274
+ fit = mSource ->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( la ) );
280
275
while ( fit.nextFeature( feature ) )
281
276
{
282
277
Direction directionType = mDefaultDirection;
@@ -388,5 +383,5 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
388
383
} // for (it = pl.begin(); it != pl.end(); ++it)
389
384
}
390
385
emit buildProgress( ++step, featureCount );
391
- } // while( vl ->nextFeature(feature) )
386
+ } // while( mSource ->nextFeature(feature) )
392
387
} // makeGraph( QgsGraphBuilderInterface *builder, const QVector< QgsPointXY >& additionalPoints, QVector< QgsPointXY >& tiedPoint )
0 commit comments