36 : mFeaturePool( pool )
38 , mMapCrs( useMapCrs )
50 QgsDebugMsg( QStringLiteral(
"Shrug. What shall we do with a geometry that cannot be converted?" ) );
62 return mFeaturePool->layerPtr();
67 return mFeaturePool->layerId();
77 return QStringLiteral(
"%1:%2" ).arg( mFeaturePool->layerName() ).arg( mFeature.id() );
82 return layerId() == other.
layerId() && mFeature.id() == other.mFeature.
id();
87 return layerId() != other.
layerId() || mFeature.id() != other.mFeature.
id();
97 nextLayerFeature(
true );
102 mLayerIt = rh.mLayerIt;
103 mFeatureIt = rh.mFeatureIt;
104 mParent = rh.mParent;
105 mCurrentFeature = qgis::make_unique<LayerFeature>( *rh.mCurrentFeature.get() );
125 Q_ASSERT( mCurrentFeature );
126 return *mCurrentFeature;
131 return mLayerIt != other.mLayerIt || mFeatureIt != other.mFeatureIt;
136 nextLayerFeature(
false );
139 bool QgsGeometryCheckerUtils::LayerFeatures::iterator::nextLayerFeature(
bool begin )
141 if ( !
begin && nextFeature(
false ) )
145 while ( nextLayer(
begin ) )
148 if ( nextFeature(
true ) )
154 mFeatureIt = QgsFeatureIds::const_iterator();
155 mCurrentFeature.reset();
159 bool QgsGeometryCheckerUtils::LayerFeatures::iterator::nextLayer(
bool begin )
167 if ( mLayerIt == mParent->mLayerIds.end() )
171 if ( mParent->mGeometryTypes.contains( mParent->mFeaturePools[*mLayerIt]->geometryType() ) )
173 mFeatureIt = mParent->mFeatureIds[*mLayerIt].constBegin();
181 bool QgsGeometryCheckerUtils::LayerFeatures::iterator::nextFeature(
bool begin )
184 const QgsFeatureIds &featureIds = mParent->mFeatureIds[*mLayerIt];
191 if ( mFeatureIt == featureIds.end() )
195 if ( mParent->mFeedback )
196 mParent->mFeedback->setProgress( mParent->mFeedback->progress() + 1.0 );
200 mCurrentFeature = qgis::make_unique<LayerFeature>( featurePool, feature, mParent->mContext, mParent->mUseMapCrs );
211 const QMap<QString, QgsFeatureIds> &featureIds,
212 const QList<QgsWkbTypes::GeometryType> &geometryTypes,
216 : mFeaturePools( featurePools )
217 , mFeatureIds( featureIds )
218 , mLayerIds( featurePools.keys() )
219 , mGeometryTypes( geometryTypes )
220 , mFeedback( feedback )
221 , mContext( context )
222 , mUseMapCrs( useMapCrs )
226 const QList<QString> &layerIds,
const QgsRectangle &extent,
227 const QList<QgsWkbTypes::GeometryType> &geometryTypes,
229 : mFeaturePools( featurePools )
230 , mLayerIds( layerIds )
232 , mGeometryTypes( geometryTypes )
233 , mContext( context )
236 for (
const QString &layerId : layerIds )
239 if ( geometryTypes.contains( featurePool->
geometryType() ) )
253 return iterator( mLayerIds.constBegin(),
this );
258 return iterator( mLayerIds.end(),
this );
265 return qgis::make_unique<QgsGeos>( geometry, tolerance );
288 QList<const QgsLineString *> rings;
291 rings.append( exterior );
293 for (
int iInt = 0, nInt = polygon->
numInteriorRings(); iInt < nInt; ++iInt )
297 rings.append( interior );
305 if ( qgsgeometry_cast<QgsGeometryCollection *>( geom ) )
308 for (
int nParts = geom->
partCount(), iPart = nParts - 1; iPart >= 0; --iPart )
310 if ( !qgsgeometry_cast<QgsSurface *>( geomCollection->
geometryN( iPart ) ) )
320 double nom = std::fabs( ( p2.
y() - p1.
y() ) * q.
x() - ( p2.
x() - p1.
x() ) * q.
y() + p2.
x() * p1.
y() - p2.
y() * p1.
x() );
321 double dx = p2.
x() - p1.
x();
322 double dy = p2.
y() - p1.
y();
323 return nom / std::sqrt( dx * dx + dy * dy );
329 for (
int i = 0 + excludeExtremities; i < nVerts - 1 - excludeExtremities; ++i )
344 QList<QgsPoint> intersections;
346 bool intersection =
false;
347 for (
int i = 0, n = line1->
vertexCount() - 1; i < n; ++i )
349 for (
int j = 0, m = line2->
vertexCount() - 1; j < m; ++j )
357 intersections.append( inter );
361 return intersections;
369 for (
int iPart1 = 0, nParts1 = geom1->
partCount(); iPart1 < nParts1; ++iPart1 )
371 for (
int iRing1 = 0, nRings1 = geom1->
ringCount( iPart1 ); iRing1 < nRings1; ++iRing1 )
373 for (
int iVert1 = 0, jVert1 = 1, nVerts1 = geom1->
vertexCount( iPart1, iRing1 ); jVert1 < nVerts1; iVert1 = jVert1++ )
377 double lambdap1 = 0.;
390 for (
int iPart2 = 0, nParts2 = geom2->
partCount(); iPart2 < nParts2; ++iPart2 )
392 for (
int iRing2 = 0, nRings2 = geom2->
ringCount( iPart2 ); iRing2 < nRings2; ++iRing2 )
394 for (
int iVert2 = 0, jVert2 = 1, nVerts2 = geom2->
vertexCount( iPart2, iRing2 ); jVert2 < nVerts2; iVert2 = jVert2++ )
403 double lambdaq1 =
QgsVector( q1.
x() - p1.
x(), q1.
y() - p1.
y() ) * d;
404 double lambdaq2 =
QgsVector( q2.
x() - p1.
x(), q2.
y() - p1.
y() ) * d;
405 if ( lambdaq1 > lambdaq2 )
407 std::swap( lambdaq1, lambdaq2 );
409 double lambda1 = std::max( lambdaq1, lambdap1 );
410 double lambda2 = std::min( lambdaq2, lambdap2 );
411 len += std::max( 0., lambda2 - lambda1 );