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,
BooleanEncodedValue accessEnc,
DecimalEncodedValue speedEnc,
Double speed,
double pNonZeroLoop,
double pBothDir,
double pRandomDistanceOffset) |
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 double |
calcWeightWithTurnWeightWithAccess(Weighting weighting,
EdgeIteratorState edgeState,
boolean reverse,
int 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 edgeId,
boolean reverse)
Creates an edge key, i.e.
|
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 List<Snap> |
createRandomSnaps(BBox bbox,
LocationIndex locationIndex,
Random rnd,
int numPoints,
boolean acceptTower,
EdgeFilter filter) |
static int |
getAdjNode(Graph g,
int edge,
int adjNode) |
static double |
getDistance(int from,
int to,
NodeAccess nodeAccess) |
static CHEdgeIteratorState |
getEdge(CHGraph graph,
int base,
int adj) |
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 Snap |
getRandomSnap(LocationIndex locationIndex,
Random rnd,
BBox bbox,
EdgeFilter filter) |
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 double |
randomDoubleInRange(Random rnd,
double min,
double max) |
static int |
reverseEdgeKey(int edgeKey)
Returns the edgeKey of the opposite direction
|
static EdgeIteratorState |
setSpeed(double averageSpeed,
boolean fwd,
boolean bwd,
FlagEncoder encoder,
EdgeIteratorState edge) |
static void |
setSpeed(double fwdSpeed,
double bwdSpeed,
FlagEncoder encoder,
Collection<EdgeIteratorState> edges) |
static void |
setSpeed(double fwdSpeed,
double bwdSpeed,
FlagEncoder encoder,
EdgeIteratorState... edges) |
static IntsRef |
setSpeed(double fwdSpeed,
double bwdSpeed,
FlagEncoder encoder,
IntsRef edgeFlags) |
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, BooleanEncodedValue accessEnc, DecimalEncodedValue speedEnc, Double speed, double pNonZeroLoop, double pBothDir, double pRandomDistanceOffset)
speed
- if null a random speed will be assign to every edgepublic 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 List<Snap> createRandomSnaps(BBox bbox, LocationIndex locationIndex, Random rnd, int numPoints, boolean acceptTower, EdgeFilter filter)
public static Snap getRandomSnap(LocationIndex locationIndex, Random rnd, BBox bbox, EdgeFilter filter)
public static double randomDoubleInRange(Random rnd, double min, double max)
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 CHEdgeIteratorState getEdge(CHGraph graph, int base, int adj)
public static int createEdgeKey(int nodeA, int nodeB, int edgeId, boolean reverse)
public static int createEdgeKey(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 setSpeed(double fwdSpeed, double bwdSpeed, FlagEncoder encoder, IntsRef edgeFlags)
public static void setSpeed(double fwdSpeed, double bwdSpeed, FlagEncoder encoder, EdgeIteratorState... edges)
public static void setSpeed(double fwdSpeed, double bwdSpeed, FlagEncoder encoder, Collection<EdgeIteratorState> edges)
public static EdgeIteratorState setSpeed(double averageSpeed, boolean fwd, boolean bwd, FlagEncoder encoder, EdgeIteratorState edge)
public static void updateDistancesFor(Graph g, int node, double lat, double lon)
public static double calcWeightWithTurnWeightWithAccess(Weighting weighting, EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId)
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–2021. All rights reserved.