42 int QgsSnapper::snapPoint(
const QPoint& startPoint, QList<QgsSnappingResult>& snappingResult,
const QList<QgsPoint>& excludePoints )
44 snappingResult.clear();
46 QMultiMap<double, QgsSnappingResult> snappingResultList;
47 QMultiMap<double, QgsSnappingResult> currentResultList;
54 QList<QgsSnapper::SnapLayer>::iterator snapLayerIt;
57 if ( !snapLayerIt->mLayer->hasGeometryType() )
64 if ( snapLayerIt->mLayer->snapWithContext( layerCoordPoint, tolerance,
65 currentResultList, snapLayerIt->mSnapTo ) != 0 )
71 QMultiMap<double, QgsSnappingResult>::iterator currentResultIt;
72 for ( currentResultIt = currentResultList.begin(); currentResultIt != currentResultList.end(); ++currentResultIt )
76 newResult = currentResultIt.value();
80 snappingResultList.insert( sqrt( newResult.
snappedVertex.
sqrDist( mapCoordPoint ) ), newResult );
88 QMultiMap<double, QgsSnappingResult>::iterator evalIt = snappingResultList.begin();
89 if ( evalIt == snappingResultList.end() )
97 snappingResult.push_back( evalIt.value() );
102 double tolerance = 0.000001;
103 double minDistance = evalIt.key();
105 for ( evalIt = snappingResultList.begin(); evalIt != snappingResultList.end(); ++evalIt )
107 if ( evalIt.key() > ( minDistance + tolerance ) )
111 snappingResult.push_back( evalIt.value() );
118 for ( ; evalIt != snappingResultList.end(); ++evalIt )
120 snappingResult.push_back( evalIt.value() );
142 QList<double> keysToRemove;
144 QMultiMap<double, QgsSnappingResult>::iterator result_it = list.begin();
145 for ( ; result_it != list.end(); ++result_it )
147 currentSnappingResult = result_it.value();
151 if ( excludeList.contains( currentResultPoint ) )
153 keysToRemove.push_back( result_it.key() );
158 QList<double>::const_iterator remove_it = keysToRemove.constBegin();
159 for ( ; remove_it != keysToRemove.constEnd(); ++remove_it )
161 list.remove( *remove_it );