PriorityCode.java

  1. package org.heigit.ors.routing.graphhopper.extensions.util;

  2. /**
  3.  * Used to store a priority value in the way flags of an edge. Used in combination with
  4.  * PriorityWeighting
  5.  *
  6.  * @author Peter Karich
  7.  */
  8. public enum PriorityCode {
  9.     WORST(0),
  10.     AVOID_AT_ALL_COSTS(1),
  11.     REACH_DEST(2),
  12.     AVOID_IF_POSSIBLE(3),
  13.     UNCHANGED(4),
  14.     PREFER(5),
  15.     VERY_NICE(6),
  16.     BEST(7);
  17.     private final int value;

  18.     PriorityCode(int value) {
  19.         this.value = value;
  20.     }

  21.     public int getValue() {
  22.         return value;
  23.     }

  24.     /**
  25.      * This method returns the PriorityCode.value in a range between 0 and 1 suitable for direct usage in a Weighting.
  26.      */
  27.     public static double getFactor(int val) {
  28.         return (double) val / BEST.getValue();
  29.     }

  30. }