Exemplo n.º 1
0
        public void OnSnapPointRequested(SnapPointRequestedEventArgs e)
        {
            // If there are no restrictions active, don't interfere
            if (!activeRestrictions.Any())
            {
                return;
            }

            double tolerance        = MapConfig.GetProjectedMouseTolerance(_context.Map);
            var    snapPointChecker = new SnapPointCandidateChecker(new Coordinate(e.PointX, e.PointY), tolerance);

            // First try to snap to an intersection of two restrictions (if possible)
            bool success = snapPointChecker.ContainsBetterCandidate(c => GetIntersectionBetweenRestrictions(c, tolerance));

            // Then try to snap to an intersection of a restriction with layer geometries
            if (!success)
            {
                success = snapPointChecker.ContainsBetterCandidate(c => GetIntersectionsWithLayerFeatures(c, tolerance));
            }

            // Try a regular snap to the restrictions
            if (!success)
            {
                success = snapPointChecker.ContainsBetterCandidateWithoutTolerance(GetSnapPoints);
            }

            e.SnappedX = snapPointChecker.BestSnapPoint.X;
            e.SnappedY = snapPointChecker.BestSnapPoint.Y;
            e.IsFinal  = true;
            e.IsFound  = true;
        }
Exemplo n.º 2
0
 private void OnSnapPointRequested(object sender, SnapPointRequestedEventArgs e)
 {
     _snapRestrictionService.OnSnapPointRequested(e);
 }