Class SimplifyWayAction

    • Constructor Detail

    • Method Detail

      • askSimplifyWays

        public static double askSimplifyWays​(String text,
                                             boolean auto)
        Asks the user for max-err value used to simplify ways, if not remembered before
        Parameters:
        text - the text being shown
        auto - whether it's called automatically (conversion) or by the user
        Returns:
        the max-err value or -1 if canceled
        Since:
        15419
      • askSimplifyWays

        public static double askSimplifyWays​(List<Way> ways,
                                             String text,
                                             boolean auto)
        Asks the user for max-err value used to simplify ways, if not remembered before
        Parameters:
        ways - the ways that are being simplified (to show estimated number of nodes to be removed)
        text - the text being shown
        auto - whether it's called automatically (conversion) or by the user
        Returns:
        the max-err value or -1 if canceled
        Since:
        16566
      • isRequiredNode

        protected static boolean isRequiredNode​(Way way,
                                                Node node,
                                                Set<Node> multipleUseNodes)
        Replies true if node is a required node which can't be removed in order to simplify the way.
        Parameters:
        way - the way to be simplified
        node - the node to check
        multipleUseNodes - set of nodes which is used more than once in the way
        Returns:
        true if node is a required node which can't be removed in order to simplify the way.
      • getMultiUseNodes

        private static Set<NodegetMultiUseNodes​(Way w)
        Calculate a set of nodes which occurs more than once in the way
        Parameters:
        w - the way
        Returns:
        a set of nodes which occurs more than once in the way
      • simplifyWaysCountNodesRemoved

        public static int simplifyWaysCountNodesRemoved​(List<Way> ways,
                                                        double threshold)
        Runs the commands to simplify the ways with the given threshold
        Parameters:
        ways - the ways to simplify
        threshold - the max error threshold
        Returns:
        The number of nodes removed from the ways (does not double-count)
        Since:
        16566
      • simplifyWays

        public static void simplifyWays​(List<Way> ways,
                                        double threshold)
        Runs the commands to simplify the ways with the given threshold
        Parameters:
        ways - the ways to simplify
        threshold - the max error threshold
        Since:
        15419
      • buildSimplifyWaysCommand

        private static SequenceCommand buildSimplifyWaysCommand​(List<Way> ways,
                                                                double threshold)
        Creates the commands to simplify the ways with the given threshold
        Parameters:
        ways - the ways to simplify
        threshold - the max error threshold
        Returns:
        The command to simplify ways
        Since:
        16566 (private)
      • createSimplifyCommand

        public static SequenceCommand createSimplifyCommand​(Way w)
        Creates the SequenceCommand to simplify a way with default threshold.
        Parameters:
        w - the way to simplify
        Returns:
        The sequence of commands to run
        Since:
        15419
      • createSimplifyCommand

        public static SequenceCommand createSimplifyCommand​(Way w,
                                                            double threshold)
        Creates the SequenceCommand to simplify a way with a given threshold.
        Parameters:
        w - the way to simplify
        threshold - the max error threshold
        Returns:
        The sequence of commands to run
        Since:
        15419
      • buildSimplifiedNodeList

        protected static void buildSimplifiedNodeList​(List<Node> wnew,
                                                      int from,
                                                      int to,
                                                      double threshold,
                                                      List<Node> simplifiedNodes)
        Builds the simplified list of nodes for a way segment given by a lower index from and an upper index to
        Parameters:
        wnew - the way to simplify
        from - the lower index
        to - the upper index
        threshold - the max error threshold
        simplifiedNodes - list that will contain resulting nodes
      • dist

        private static double dist​(double lat1,
                                   double lon1,
                                   double lat2,
                                   double lon2)
      • course

        private static double course​(double lat1,
                                     double lon1,
                                     double lat2,
                                     double lon2)
      • xtd

        private static double xtd​(double lat1,
                                  double lon1,
                                  double lat2,
                                  double lon2,
                                  double lat3,
                                  double lon3)