public class GHUtility extends Object
Modifier and Type | Class and Description |
---|---|
static class |
GHUtility.DisabledEdgeIterator
This edge iterator can be used in tests to mock specific iterator behaviour via overloading
certain methods.
|
static class |
GHUtility.DisabledNodeAccess
This node access can be used in tests to mock specific iterator behaviour via overloading
certain methods.
|
Constructor and Description |
---|
GHUtility() |
Modifier and Type | Method and Description |
---|---|
static void |
addRandomTurnCosts(Graph graph,
long seed,
EncodingManager em,
FlagEncoder encoder,
int maxTurnCost,
TurnCostStorage turnCostStorage) |
static Set<Integer> |
asSet(int... values) |
static void |
buildRandomGraph(Graph graph,
Random random,
int numNodes,
double meanDegree,
boolean allowLoops,
boolean allowZeroDistance,
DecimalEncodedValue randomSpeedEnc,
double pNonZeroLoop,
double pBothDir,
double pRandomOffset) |
static long |
calcMillisWithTurnMillis(Weighting weighting,
EdgeIteratorState edgeState,
boolean reverse,
int prevOrNextEdgeId) |
static double |
calcWeightWithTurnWeight(Weighting weighting,
EdgeIteratorState edgeState,
boolean reverse,
int prevOrNextEdgeId)
Calculates the weight of a given edge like
Weighting.calcEdgeWeight(com.graphhopper.util.EdgeIteratorState, boolean) and adds the transition
cost (the turn weight, Weighting.calcTurnWeight(int, int, int) ) associated with transitioning from/to the edge with ID prevOrNextEdgeId. |
static Graph |
copyTo(Graph fromGraph,
Graph toGraph) |
static int |
count(EdgeIterator iter)
Counts reachable edges.
|
static BBox |
createBBox(EdgeIteratorState edgeState) |
static int |
createEdgeKey(int nodeA,
int nodeB,
int edgeId,
boolean reverse)
Creates unique positive number for specified edgeId taking into account the direction defined
by nodeA, nodeB and reverse.
|
static EdgeIteratorState |
createMockedEdgeIteratorState(double distance,
IntsRef flags) |
static EdgeIteratorState |
createMockedEdgeIteratorState(double distance,
IntsRef flags,
int base,
int adj,
int edge,
int origFirst,
int origLast) |
static int |
getAdjNode(Graph g,
int edge,
int adjNode) |
static double |
getDistance(int from,
int to,
NodeAccess nodeAccess) |
static EdgeIteratorState |
getEdge(Graph graph,
int base,
int adj) |
static int |
getEdgeFromEdgeKey(int edgeKey) |
static List<Integer> |
getEdgeIds(EdgeIterator iter) |
static Set<Integer> |
getNeighbors(EdgeIterator iter) |
static String |
getNodeInfo(CHGraph g,
int nodeId,
EdgeFilter filter) |
static String |
getNodeInfo(Graph g,
int nodeId,
EdgeFilter filter) |
static List<String> |
getProblems(Graph g)
This method could throw an exception if problems like index out of bounds etc
|
static boolean |
isSameEdgeKeys(int edgeKey1,
int edgeKey2)
Returns if the specified edgeKeys (created by createEdgeKey) are identical regardless of the
direction.
|
static GraphHopperStorage |
newStorage(GraphHopperStorage store)
Create a new storage from the specified one without copying the data.
|
static void |
printEdgeInfo(Graph g,
FlagEncoder encoder) |
static void |
printGraphForUnitTest(Graph g,
FlagEncoder encoder) |
static void |
printGraphForUnitTest(Graph g,
FlagEncoder encoder,
BBox bBox) |
static void |
printInfo(Graph g,
int startNode,
int counts,
EdgeFilter filter) |
static int |
reverseEdgeKey(int edgeKey)
Returns the edgeKey of the opposite direction
|
static EdgeIteratorState |
setProperties(EdgeIteratorState edge,
FlagEncoder encoder,
double averageSpeed,
boolean fwd,
boolean bwd) |
static EdgeIteratorState |
setProperties(EdgeIteratorState edge,
FlagEncoder encoder,
double fwdSpeed,
double bwdSpeed) |
static IntsRef |
setProperties(IntsRef edgeFlags,
FlagEncoder encoder,
double averageSpeed,
boolean fwd,
boolean bwd) |
static IntsRef |
setProperties(IntsRef edgeFlags,
FlagEncoder encoder,
double fwdSpeed,
double bwdSpeed) |
static Graph |
shuffle(Graph g,
Graph sortedGraph) |
static Graph |
sortDFS(Graph g,
Graph sortedGraph)
Sorts the graph according to depth-first search traversal.
|
static void |
updateDistancesFor(Graph g,
int node,
double lat,
double lon) |
public static List<String> getProblems(Graph g)
public static int count(EdgeIterator iter)
public static Set<Integer> getNeighbors(EdgeIterator iter)
public static List<Integer> getEdgeIds(EdgeIterator iter)
public static void printEdgeInfo(Graph g, FlagEncoder encoder)
public static void printGraphForUnitTest(Graph g, FlagEncoder encoder)
public static void printGraphForUnitTest(Graph g, FlagEncoder encoder, BBox bBox)
public static void buildRandomGraph(Graph graph, Random random, int numNodes, double meanDegree, boolean allowLoops, boolean allowZeroDistance, DecimalEncodedValue randomSpeedEnc, double pNonZeroLoop, double pBothDir, double pRandomOffset)
public static double getDistance(int from, int to, NodeAccess nodeAccess)
public static void addRandomTurnCosts(Graph graph, long seed, EncodingManager em, FlagEncoder encoder, int maxTurnCost, TurnCostStorage turnCostStorage)
public static void printInfo(Graph g, int startNode, int counts, EdgeFilter filter)
public static String getNodeInfo(CHGraph g, int nodeId, EdgeFilter filter)
public static String getNodeInfo(Graph g, int nodeId, EdgeFilter filter)
public static Graph sortDFS(Graph g, Graph sortedGraph)
public static Graph copyTo(Graph fromGraph, Graph toGraph)
public static GraphHopperStorage newStorage(GraphHopperStorage store)
public static int getAdjNode(Graph g, int edge, int adjNode)
public static EdgeIteratorState createMockedEdgeIteratorState(double distance, IntsRef flags)
public static EdgeIteratorState createMockedEdgeIteratorState(double distance, IntsRef flags, int base, int adj, int edge, int origFirst, int origLast)
public static EdgeIteratorState getEdge(Graph graph, int base, int adj)
public static int createEdgeKey(int nodeA, int nodeB, int edgeId, boolean reverse)
public static boolean isSameEdgeKeys(int edgeKey1, int edgeKey2)
public static int reverseEdgeKey(int edgeKey)
public static int getEdgeFromEdgeKey(int edgeKey)
public static IntsRef setProperties(IntsRef edgeFlags, FlagEncoder encoder, double averageSpeed, boolean fwd, boolean bwd)
public static EdgeIteratorState setProperties(EdgeIteratorState edge, FlagEncoder encoder, double fwdSpeed, double bwdSpeed)
public static IntsRef setProperties(IntsRef edgeFlags, FlagEncoder encoder, double fwdSpeed, double bwdSpeed)
public static EdgeIteratorState setProperties(EdgeIteratorState edge, FlagEncoder encoder, double averageSpeed, boolean fwd, boolean bwd)
public static void updateDistancesFor(Graph g, int node, double lat, double lon)
public static double calcWeightWithTurnWeight(Weighting weighting, EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId)
Weighting.calcEdgeWeight(com.graphhopper.util.EdgeIteratorState, boolean)
and adds the transition
cost (the turn weight, Weighting.calcTurnWeight(int, int, int)
) associated with transitioning from/to the edge with ID prevOrNextEdgeId.prevOrNextEdgeId
- if reverse is false this has to be the previous edgeId, if true it
has to be the next edgeId in the direction from start to end.public static long calcMillisWithTurnMillis(Weighting weighting, EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId)
public static BBox createBBox(EdgeIteratorState edgeState)
Copyright © 2012–2020. All rights reserved.