Class ImproveWayAccuracyHelper


  • final class ImproveWayAccuracyHelper
    extends java.lang.Object
    This static class contains functions used to find target way, node to move or segment to divide.
    • Method Detail

      • findWay

        public static Way findWay​(MapView mv,
                                  java.awt.Point p)
        Finds the way to work on. If the mouse is on the node, extracts one of the ways containing it. If the mouse is on the way, simply returns it.
        Parameters:
        mv - the current map view
        p - the cursor position
        Returns:
        Way or null in case there is nothing under the cursor.
      • findCandidateNode

        public static Node findCandidateNode​(MapView mv,
                                             Way w,
                                             java.awt.Point p)
        Returns the nearest node to cursor. All nodes that are “behind” segments are neglected. This is to avoid way self-intersection after moving the candidateNode to a new place.
        Parameters:
        mv - the current map view
        w - the way to check
        p - the cursor position
        Returns:
        nearest node to cursor
      • ensureCandidateIsNotBehindSegments

        private static boolean ensureCandidateIsNotBehindSegments​(java.lang.Iterable<Pair<Node,​Node>> wpps,
                                                                  Node n,
                                                                  EastNorth pEN,
                                                                  EastNorth nEN)
        Check to see if a candidate node is underneath a way segment
        Parameters:
        wpps - The pairs of nodes to check for crossing way segments
        n - The current node to check
        pEN - The cursor east-north position
        nEN - The node east-north position
        Returns:
        true if the candidate node is underneath a way segment
      • findCandidateSegment

        public static WaySegment findCandidateSegment​(MapView mv,
                                                      Way w,
                                                      java.awt.Point p)
        Returns the nearest way segment to cursor. The distance to segment ab is the length of altitude from p to ab (say, c) or the minimum distance from p to a or b if c is out of ab.

        The priority is given to segments where c is in ab. Otherwise, a segment with the largest angle apb is chosen.

        Parameters:
        mv - the current map view
        w - the way to check
        p - the cursor position
        Returns:
        nearest way segment to cursor