/** * This method returns the spatialId stored in the specified flags or -1 if not enabled for this encoder. */ public int getSpatialId(long flags) { if (spatialEncoder == null) return -1; return (int) spatialEncoder.getValue(flags); }
@Override public boolean isTurnRestricted(long flags) { if (maxTurnCosts == 0) return false; else if (maxTurnCosts == 1) return (flags & turnRestrictionBit) != 0; return turnCostEncoder.getValue(flags) == maxTurnCosts; }
@Override public double getTurnCost(long flags) { if (maxTurnCosts == 0) return 0; else if (maxTurnCosts == 1) return ((flags & turnRestrictionBit) == 0) ? 0 : Double.POSITIVE_INFINITY; long cost = turnCostEncoder.getValue(flags); if (cost == maxTurnCosts) return Double.POSITIVE_INFINITY; return cost; }
public AccessValue getAccessValue(long flags) { int accessValue = (int) accessEncoder.getValue(flags); switch (accessValue) { case 0: return AccessValue.ACCESSIBLE; // NOT_ACCESSIBLE_KEY case 3: return AccessValue.NOT_ACCESSIBLE; default: return AccessValue.EVENTUALLY_ACCESSIBLE; } }
long getTime(long flags) { return time.getValue(flags); }
int getTransfers(long flags) { return (int) transfers.getValue(flags); }
public boolean isTransportModeFord(long flags) { return transportModeEncoder.getValue(flags) == this.transportModeFordValue; }
@Override public double getDouble(long flags, int key) { switch (key) { case PriorityWeighting.KEY: return (double) priorityWayEncoder.getValue(flags) / BEST.getValue(); case MotorcycleFlagEncoder.CURVATURE_KEY: return (double) curvatureEncoder.getValue(flags) / 10; default: return super.getDouble(flags, key); } }
/** * Swap the contents controlled by this value encoder with the given value. * <p> * * @return the new flags */ public long swap(long flags, EncodedValue otherEncoder) { long otherValue = otherEncoder.getValue(flags); flags = otherEncoder.setValue(flags, getValue(flags)); return setValue(flags, otherValue); } }
public boolean isTransportModeTunnel(EdgeIteratorState edge) { return transportModeEncoder.getValue(edge.getFlags()) == this.transportModeTunnelValue; }
public int getHighway(EdgeIteratorState edge) { return (int) highwayEncoder.getValue(edge.getFlags()); }
public int getTransportMode(EdgeIteratorState edge) { return (int) transportModeEncoder.getValue(edge.getFlags()); }
public int getSurface(EdgeIteratorState edge) { return (int) surfaceEncoder.getValue(edge.getFlags()); }
public GtfsStorage.EdgeType getEdgeType(long flags) { return GtfsStorage.EdgeType.values()[(int) type.getValue(flags)]; }
@Override public double getDouble(long flags, int key) { switch (key) { case PriorityWeighting.KEY: return (double) priorityWayEncoder.getValue(flags) / BEST.getValue(); default: return super.getDouble(flags, key); } }
@Override public double getDouble(long flags, int key) { switch (key) { case PriorityWeighting.KEY: return (double) priorityWayEncoder.getValue(flags) / BEST.getValue(); default: return super.getDouble(flags, key); } }
@Override public InstructionAnnotation getAnnotation(long flags, Translation tr) { int paveType = 0; // paved if (isBool(flags, K_UNPAVED)) paveType = 1; // unpaved int wayType = (int) wayTypeEncoder.getValue(flags); String wayName = getWayName(paveType, wayType, tr); return new InstructionAnnotation(0, wayName); }
@Override public long handleRelationTags(ReaderRelation relation, long oldRelationFlags) { oldRelationFlags = super.handleRelationTags(relation, oldRelationFlags); int code = 0; if (relation.hasTag("route", "mtb")) code = PREFER.getValue(); int oldCode = (int) relationCodeEncoder.getValue(oldRelationFlags); if (oldCode < code) return relationCodeEncoder.setValue(0, code); return oldRelationFlags; }
protected void assertPriority(int expectedPrio, ReaderWay way, long relationFlags) { assertEquals(expectedPrio, encoder.handlePriority(way, 18, (int) encoder.relationCodeEncoder.getValue(relationFlags))); }
@Test public void testSetValue() { EncodedValue instance = new EncodedValue("test", 6, 4, 1, 5, 10); assertEquals(10, instance.getValue(instance.setValue(0, 10))); instance = new EncodedValue("test", 0, 4, 1, 5, 10); assertEquals(10, instance.getValue(instance.setValue(0, 10))); instance = new EncodedValue("test", 0, 4, 1, 5, 10); assertEquals(5, instance.getValue(instance.setDefaultValue(0))); }