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;
61 if ( snapLayerIt->mLayer->snapWithContext( layerCoordPoint, tolerance,
62 currentResultList, snapLayerIt->mSnapTo ) != 0 )
68 QMultiMap<double, QgsSnappingResult>::iterator currentResultIt;
69 for ( currentResultIt = currentResultList.begin(); currentResultIt != currentResultList.end(); ++currentResultIt )
73 newResult = currentResultIt.value();
77 snappingResultList.insert( sqrt( newResult.
snappedVertex.
sqrDist( mapCoordPoint ) ), newResult );
85 QMultiMap<double, QgsSnappingResult>::iterator evalIt = snappingResultList.begin();
86 if ( evalIt == snappingResultList.end() )
94 snappingResult.push_back( evalIt.value() );
99 double tolerance = 0.000001;
100 double minDistance = evalIt.key();
102 for ( evalIt = snappingResultList.begin(); evalIt != snappingResultList.end(); ++evalIt )
104 if ( evalIt.key() > ( minDistance + tolerance ) )
108 snappingResult.push_back( evalIt.value() );
115 for ( ; evalIt != snappingResultList.end(); ++evalIt )
117 snappingResult.push_back( evalIt.value() );
139 QList<double> keysToRemove;
141 QMultiMap<double, QgsSnappingResult>::iterator result_it = list.begin();
142 for ( ; result_it != list.end(); ++result_it )
144 currentSnappingResult = result_it.value();
148 if ( excludeList.contains( currentResultPoint ) )
150 keysToRemove.push_back( result_it.key() );
155 QList<double>::const_iterator remove_it = keysToRemove.constBegin();
156 for ( ; remove_it != keysToRemove.constEnd(); ++remove_it )
158 list.remove( *remove_it );