Tabnine Logo
FootFlagEncoder
Code IndexAdd Tabnine to your IDE (free)

How to use
FootFlagEncoder
in
com.graphhopper.routing.util

Best Java code snippets using com.graphhopper.routing.util.FootFlagEncoder (Showing top 20 results out of 315)

origin: graphhopper/graphhopper

return new FootFlagEncoder(configuration);
origin: graphhopper/graphhopper

@Test
public void testFerrySpeed() {
  ReaderWay way = new ReaderWay(1);
  way.setTag("route", "ferry");
  // a bit longer than an hour
  way.setTag("duration:seconds", "4000");
  long flags = footEncoder.handleWayTags(way, footEncoder.acceptWay(way), 0);
  assertTrue(footEncoder.getSpeed(flags) > footEncoder.getMaxSpeed());
  assertEquals(20, footEncoder.getSpeed(flags), .1);
}
origin: graphhopper/graphhopper

@Override
public long handleWayTags(ReaderWay way, long allowed, long relationFlags) {
  if (!isAccept(allowed))
    return 0;
  long flags = 0;
  if (!isFerry(allowed)) {
    String sacScale = way.getTag("sac_scale");
    if (sacScale != null) {
      if ("hiking".equals(sacScale))
        flags = speedEncoder.setDoubleValue(flags, MEAN_SPEED);
      else
        flags = speedEncoder.setDoubleValue(flags, SLOW_SPEED);
    } else {
      flags = speedEncoder.setDoubleValue(flags, MEAN_SPEED);
    }
    flags |= directionBitMask;
    boolean isRoundabout = way.hasTag("junction", "roundabout") || way.hasTag("junction", "circular");
    if (isRoundabout)
      flags = setBool(flags, K_ROUNDABOUT, true);
  } else {
    double ferrySpeed = getFerrySpeed(way);
    flags = setSpeed(flags, ferrySpeed);
    flags |= directionBitMask;
  }
  int priorityFromRelation = 0;
  if (relationFlags != 0)
    priorityFromRelation = (int) relationCodeEncoder.getValue(relationFlags);
  flags = priorityWayEncoder.setValue(flags, handlePriority(way, priorityFromRelation));
  return flags;
}
origin: graphhopper/graphhopper

sidewalkValues.add("right");
setBlockByDefault(false);
absoluteBarriers.add("fence");
potentialBarriers.add("gate");
init();
origin: graphhopper/graphhopper

@Test
public void testBlockByDefault() {
  FootFlagEncoder tmpFootEncoder = new FootFlagEncoder();
  new EncodingManager(tmpFootEncoder);
  node.setTag("barrier", "gate");
  assertTrue(tmpFootEncoder.handleNodeTags(node) == 0);
  node.setTag("access", "no");
  assertTrue(tmpFootEncoder.handleNodeTags(node) > 0);
  assertTrue(tmpFootEncoder.handleNodeTags(node) > 0);
  node.setTag("barrier", "fence");
  node.setTag("access", "yes");
  assertTrue(tmpFootEncoder.handleNodeTags(node) > 0);
  tmpFootEncoder.setBlockByDefault(true);
  assertTrue(tmpFootEncoder.handleNodeTags(node) > 0);
  node.setTag("access", "yes");
  assertTrue(tmpFootEncoder.handleNodeTags(node) == 0);
  assertTrue(tmpFootEncoder.handleNodeTags(node) > 0);
  tmpFootEncoder.setBlockByDefault(false);
  assertTrue(tmpFootEncoder.handleNodeTags(node) == 0);
origin: graphhopper/graphhopper

  @Override
  public double getSpeed(long flags) {
    double speed = super.getSpeed(flags);
    if (speed == getMaxSpeed()) {
      // We cannot be sure if it was a long or a short trip
      return SHORT_TRIP_FERRY_SPEED;
    }
    return speed;
  }
}
origin: graphhopper/graphhopper

    if (way.hasTag(restrictions, restrictedValues) && !getConditionalTagInspector().isRestrictedWayConditionallyPermitted(way))
      return 0;
    return acceptPotentially;
if (way.hasTag(restrictions, restrictedValues) && !getConditionalTagInspector().isRestrictedWayConditionallyPermitted(way))
  return 0;
if (isBlockFords() && (way.hasTag("highway", "ford") || way.hasTag("ford")))
  return 0;
if (getConditionalTagInspector().isPermittedWayConditionallyRestricted(way))
  return 0;
origin: graphhopper/graphhopper

public FootFlagEncoder(PMap properties) {
  this((int) properties.getLong("speedBits", 4),
      properties.getDouble("speedFactor", 1));
  this.properties = properties;
  this.setBlockFords(properties.getBool("block_fords", true));
}
origin: graphhopper/graphhopper

@Test
public void testCompatibility() {
  EncodingManager manager = new EncodingManager("car,bike,foot");
  BikeFlagEncoder bike = (BikeFlagEncoder) manager.getEncoder("bike");
  CarFlagEncoder car = (CarFlagEncoder) manager.getEncoder("car");
  FootFlagEncoder foot = (FootFlagEncoder) manager.getEncoder("foot");
  assertNotEquals(car, bike);
  assertNotEquals(car, foot);
  assertNotEquals(car.hashCode(), bike.hashCode());
  assertNotEquals(car.hashCode(), foot.hashCode());
  FootFlagEncoder foot2 = new FootFlagEncoder();
  EncodingManager manager2 = new EncodingManager(foot2);
  assertNotEquals(foot, foot2);
  assertNotEquals(foot.hashCode(), foot2.hashCode());
  FootFlagEncoder foot3 = new FootFlagEncoder();
  EncodingManager manager3 = new EncodingManager(foot3);
  assertEquals(foot3, foot2);
  assertEquals(foot3.hashCode(), foot2.hashCode());
  try {
    new EncodingManager("car,car");
    assertTrue("do not allow duplicate flag encoders", false);
  } catch (Exception ex) {
  }
}
origin: graphhopper/graphhopper

@Test
public void testFord() {
  // by default deny access through fords!
  ReaderNode node = new ReaderNode(1, -1, -1);
  node.setTag("ford", "no");
  assertTrue(footEncoder.handleNodeTags(node) == 0);
  node = new ReaderNode(1, -1, -1);
  node.setTag("ford", "yes");
  assertTrue(footEncoder.handleNodeTags(node) > 0);
  node.setTag("foot", "yes");
  // no barrier!
  assertTrue(footEncoder.handleNodeTags(node) == 0);
  // Now let's allow fords for foot
  footEncoder.setBlockFords(Boolean.FALSE);
  node = new ReaderNode(1, -1, -1);
  node.setTag("ford", "no");
  assertTrue(footEncoder.handleNodeTags(node) == 0);
  node = new ReaderNode(1, -1, -1);
  node.setTag("ford", "yes");
  assertTrue(footEncoder.handleNodeTags(node) == 0);
}
origin: graphhopper/graphhopper

protected int handlePriority(ReaderWay way, int priorityFromRelation) {
  TreeMap<Double, Integer> weightToPrioMap = new TreeMap<>();
  if (priorityFromRelation == 0)
    weightToPrioMap.put(0d, UNCHANGED.getValue());
  else
    weightToPrioMap.put(110d, priorityFromRelation);
  collect(way, weightToPrioMap);
  // pick priority with biggest order value
  return weightToPrioMap.lastEntry().getValue();
}
origin: graphhopper/graphhopper

ReaderWay way = new ReaderWay(1);
way.setTag("highway", "cycleway");
assertEquals(PriorityCode.UNCHANGED.getValue(), footEncoder.handlePriority(way, 0));
assertEquals(PriorityCode.AVOID_IF_POSSIBLE.getValue(), footEncoder.handlePriority(way, 0));
assertEquals(PriorityCode.AVOID_IF_POSSIBLE.getValue(), footEncoder.handlePriority(way, 0));
assertEquals(PriorityCode.AVOID_IF_POSSIBLE.getValue(), footEncoder.handlePriority(way, 0));
assertEquals(PriorityCode.PREFER.getValue(), footEncoder.handlePriority(way, 0));
assertEquals(PriorityCode.UNCHANGED.getValue(), footEncoder.handlePriority(way, 0));
assertEquals(PriorityCode.UNCHANGED.getValue(), footEncoder.handlePriority(way, 0));
way.setTag("bicycle", "official");
way.setTag("sidewalk", "no");
assertEquals(PriorityCode.AVOID_IF_POSSIBLE.getValue(), footEncoder.handlePriority(way, 0));
assertEquals(PriorityCode.AVOID_IF_POSSIBLE.getValue(), footEncoder.handlePriority(way, 0));
way.setTag("sidewalk", "none");
assertEquals(PriorityCode.AVOID_IF_POSSIBLE.getValue(), footEncoder.handlePriority(way, 0));
assertEquals(PriorityCode.PREFER.getValue(), footEncoder.handlePriority(way, 0));
origin: com.graphhopper/graphhopper

sidewalkValues.add("right");
setBlockByDefault(false);
potentialBarriers.add("gate");
origin: com.graphhopper/graphhopper

if (isBlockFords() && (way.hasTag("highway", "ford") || way.hasTag("ford")))
  return 0;
origin: com.graphhopper/graphhopper-core

sidewalkValues.add("right");
setBlockByDefault(false);
absoluteBarriers.add("fence");
potentialBarriers.add("gate");
init();
origin: graphhopper/graphhopper

/**
 * @param weightToPrioMap associate a weight with every priority. This sorted map allows
 *                        subclasses to 'insert' more important priorities as well as overwrite determined priorities.
 */
void collect(ReaderWay way, TreeMap<Double, Integer> weightToPrioMap) {
  String highway = way.getTag("highway");
  if (way.hasTag("foot", "designated"))
    weightToPrioMap.put(100d, PREFER.getValue());
  double maxSpeed = getMaxSpeed(way);
  if (safeHighwayTags.contains(highway) || maxSpeed > 0 && maxSpeed <= 20) {
    weightToPrioMap.put(40d, PREFER.getValue());
    if (way.hasTag("tunnel", intendedValues)) {
      if (way.hasTag("sidewalk", sidewalksNoValues))
        weightToPrioMap.put(40d, AVOID_IF_POSSIBLE.getValue());
      else
        weightToPrioMap.put(40d, UNCHANGED.getValue());
    }
  } else if (maxSpeed > 50 || avoidHighwayTags.contains(highway)) {
    if (!way.hasTag("sidewalk", sidewalkValues))
      weightToPrioMap.put(45d, AVOID_IF_POSSIBLE.getValue());
  }
  if (way.hasTag("bicycle", "official") || way.hasTag("bicycle", "designated"))
    weightToPrioMap.put(44d, AVOID_IF_POSSIBLE.getValue());
}
origin: com.rgi-corp/graphhopper

if (isBlockFords() && (way.hasTag("highway", "ford") || way.hasTag("ford")))
  return 0;
if (way.hasTag(restrictions, restrictedValues) && !getConditionalTagInspector().isRestrictedWayConditionallyPermitted(way))
  return 0;
if (getConditionalTagInspector().isPermittedWayConditionallyRestricted(way))
  return 0;
else
origin: com.graphhopper/graphhopper-core

public FootFlagEncoder(PMap properties) {
  this((int) properties.getLong("speedBits", 4),
      properties.getDouble("speedFactor", 1));
  this.properties = properties;
  this.setBlockFords(properties.getBool("block_fords", true));
}
origin: com.graphhopper/graphhopper

protected int handlePriority( OSMWay way, int priorityFromRelation )
{
  TreeMap<Double, Integer> weightToPrioMap = new TreeMap<Double, Integer>();
  if (priorityFromRelation == 0)
    weightToPrioMap.put(0d, UNCHANGED.getValue());
  else
    weightToPrioMap.put(110d, priorityFromRelation);
  collect(way, weightToPrioMap);
  // pick priority with biggest order value
  return weightToPrioMap.lastEntry().getValue();
}
origin: com.rgi-corp/graphhopper

@Override
public long handleWayTags(ReaderWay way, long allowed, long relationFlags) {
  if (!isAccept(allowed))
    return 0;
  long flags = 0;
  if (!isFerry(allowed)) {
    String sacScale = way.getTag("sac_scale");
    if (sacScale != null) {
      if ("hiking".equals(sacScale))
        flags = speedEncoder.setDoubleValue(flags, MEAN_SPEED);
      else
        flags = speedEncoder.setDoubleValue(flags, SLOW_SPEED);
    } else {
      flags = speedEncoder.setDoubleValue(flags, MEAN_SPEED);
    }
    flags |= directionBitMask;
    boolean isRoundabout = way.hasTag("junction", "roundabout");
    if (isRoundabout)
      flags = setBool(flags, K_ROUNDABOUT, true);
  } else {
    double ferrySpeed = getFerrySpeed(way, SLOW_SPEED, MEAN_SPEED, FERRY_SPEED);
    flags = setSpeed(flags, ferrySpeed);
    flags |= directionBitMask;
  }
  int priorityFromRelation = 0;
  if (relationFlags != 0)
    priorityFromRelation = (int) relationCodeEncoder.getValue(relationFlags);
  flags = priorityWayEncoder.setValue(flags, handlePriority(way, priorityFromRelation));
  return flags;
}
com.graphhopper.routing.utilFootFlagEncoder

Javadoc

Defines bit layout for pedestrians (speed, access, surface, ...). Here we put a penalty on unsafe roads only. If you wish to also prefer routes due to beauty like hiking routes use the HikeFlagEncoder instead.

Most used methods

  • <init>
  • getMaxSpeed
  • handlePriority
  • setBlockByDefault
  • setBlockFords
  • collect
  • getFerrySpeed
  • isAccept
  • isBlockFords
  • isFerry
  • setBool
  • setSpeed
  • setBool,
  • setSpeed,
  • supports,
  • getConditionalTagInspector,
  • init,
  • acceptWay,
  • flagsDefault,
  • getReverseSpeed,
  • getSpeed,
  • getTurnCost

Popular in Java

  • Start an intent from android
  • addToBackStack (FragmentTransaction)
  • scheduleAtFixedRate (Timer)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • JOptionPane (javax.swing)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now