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.
|
Constructor and Description |
---|
GHUtility() |
Modifier and Type | Method and Description |
---|---|
static void |
addRandomTurnCosts(Graph graph,
long seed,
BooleanEncodedValue accessEnc,
DecimalEncodedValue turnCostEnc,
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 void |
checkDAVersion(String name,
int expectedVersion,
int version) |
static int |
count(EdgeIterator iter)
Counts reachable edges.
|
static int |
count(EdgeIterator iterator,
int adj) |
static int |
count(RoutingCHEdgeIterator iter) |
static BBox |
createBBox(EdgeIteratorState edgeState) |
static int |
createEdgeKey(int edgeId,
boolean isLoop,
boolean reverse)
Creates an edge key, i.e.
|
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 EdgeIteratorState |
getEdge(Graph graph,
int base,
int adj) |
static int |
getEdgeFromEdgeKey(int edgeKey) |
static List<Integer> |
getEdgeIds(EdgeIterator iter) |
static CustomArea |
getFirstDuplicateArea(List<CustomArea> areas,
String id) |
static Set<Integer> |
getNeighbors(EdgeIterator iter) |
static Set<Integer> |
getNeighbors(RoutingCHEdgeIterator iter) |
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 BaseGraph |
newGraph(BaseGraph baseGraph)
Create a new storage from the specified one without copying the data.
|
static void |
printGraphForUnitTest(Graph g,
BooleanEncodedValue accessEnc,
DecimalEncodedValue speedEnc) |
static void |
printGraphForUnitTest(Graph g,
BooleanEncodedValue accessEnc,
DecimalEncodedValue speedEnc,
BBox bBox) |
static double |
randomDoubleInRange(Random rnd,
double min,
double max) |
static List<CustomArea> |
readCountries()
Reads the country borders from the countries.geojson resource file
|
static int |
reverseEdgeKey(int edgeKey)
Returns the edgeKey of the opposite direction, be careful not to use this for loops!
|
static void |
runConcurrently(Stream<Callable<String>> callables,
int threads) |
static EdgeIteratorState |
setSpeed(double averageSpeed,
boolean fwd,
boolean bwd,
BooleanEncodedValue accessEnc,
DecimalEncodedValue avSpeedEnc,
EdgeIteratorState edge) |
static void |
setSpeed(double fwdSpeed,
double bwdSpeed,
BooleanEncodedValue accessEnc,
DecimalEncodedValue speedEnc,
Collection<EdgeIteratorState> edges) |
static void |
setSpeed(double fwdSpeed,
double bwdSpeed,
BooleanEncodedValue accessEnc,
DecimalEncodedValue speedEnc,
EdgeIteratorState... edges) |
static IntsRef |
setSpeed(double fwdSpeed,
double bwdSpeed,
BooleanEncodedValue accessEnc,
DecimalEncodedValue speedEnc,
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 int count(RoutingCHEdgeIterator iter)
public static Set<Integer> getNeighbors(RoutingCHEdgeIterator iter)
public static Set<Integer> getNeighbors(EdgeIterator iter)
public static List<Integer> getEdgeIds(EdgeIterator iter)
public static void printGraphForUnitTest(Graph g, BooleanEncodedValue accessEnc, DecimalEncodedValue speedEnc)
public static void printGraphForUnitTest(Graph g, BooleanEncodedValue accessEnc, DecimalEncodedValue speedEnc, 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, BooleanEncodedValue accessEnc, DecimalEncodedValue turnCostEnc, 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 Graph sortDFS(Graph g, Graph sortedGraph)
public static BaseGraph newGraph(BaseGraph baseGraph)
public static int getAdjNode(Graph g, int edge, int adjNode)
public static void checkDAVersion(String name, int expectedVersion, int version)
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)
IllegalArgumentException
- when there are multiple edgespublic static int count(EdgeIterator iterator, int adj)
public static int createEdgeKey(int edgeId, boolean isLoop, boolean reverse)
public static int reverseEdgeKey(int edgeKey)
public static int getEdgeFromEdgeKey(int edgeKey)
public static IntsRef setSpeed(double fwdSpeed, double bwdSpeed, BooleanEncodedValue accessEnc, DecimalEncodedValue speedEnc, IntsRef edgeFlags)
public static void setSpeed(double fwdSpeed, double bwdSpeed, BooleanEncodedValue accessEnc, DecimalEncodedValue speedEnc, EdgeIteratorState... edges)
public static void setSpeed(double fwdSpeed, double bwdSpeed, BooleanEncodedValue accessEnc, DecimalEncodedValue speedEnc, Collection<EdgeIteratorState> edges)
public static EdgeIteratorState setSpeed(double averageSpeed, boolean fwd, boolean bwd, BooleanEncodedValue accessEnc, DecimalEncodedValue avSpeedEnc, 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 List<CustomArea> readCountries()
public static CustomArea getFirstDuplicateArea(List<CustomArea> areas, String id)
public static BBox createBBox(EdgeIteratorState edgeState)
Copyright © 2012–2022. All rights reserved.