Package com.graphhopper.storage.index
Class Snap
java.lang.Object
com.graphhopper.storage.index.Snap
Result of LocationIndex lookup.
X=query coordinates S=snapped coordinates: "snapping" real coords to road N=tower or pillar node T=closest tower node XS=distance X | T--S----N
- Author:
- Peter Karich
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Whether the query point is projected onto a tower node, pillar node or somewhere within the closest edge. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
calcSnappedPoint
(DistanceCalc distCalc) Calculates the closest point on the edge from the query point.static boolean
considerEqual
(double lat, double lon, double lat2, double lon2) int
Returns the closest matching node.double
Calculates the position of the query point 'snapped' to a close road segment or node.int
boolean
isValid()
void
void
setClosestNode
(int node) void
setQueryDistance
(double dist) void
setSnappedPoint
(GHPoint3D point) void
void
setWayIndex
(int wayIndex) toString()
-
Field Details
-
INVALID_NODE
public static final int INVALID_NODE- See Also:
-
-
Constructor Details
-
Snap
public Snap(double queryLat, double queryLon)
-
-
Method Details
-
getClosestNode
public int getClosestNode()Returns the closest matching node. This is either a tower node of the base graph or a virtual node (see alsoQueryGraph.create(BaseGraph, List)
).- Returns:
INVALID_NODE
if nothing found, this should be avoided via a call of 'isValid'
-
setClosestNode
public void setClosestNode(int node) -
getQueryDistance
public double getQueryDistance()- Returns:
- the distance of the query to the snapped coordinates. In meter
-
setQueryDistance
public void setQueryDistance(double dist) -
getWayIndex
public int getWayIndex() -
setWayIndex
public void setWayIndex(int wayIndex) -
getSnappedPosition
- Returns:
- 0 if on edge. 1 if on pillar node and 2 if on tower node.
-
setSnappedPosition
-
isValid
public boolean isValid()- Returns:
- true if a closest node was found
-
getClosestEdge
-
setClosestEdge
-
getQueryPoint
-
getSnappedPoint
Calculates the position of the query point 'snapped' to a close road segment or node. Call calcSnappedPoint before, if not, an IllegalStateException is thrown. -
setSnappedPoint
-
calcSnappedPoint
Calculates the closest point on the edge from the query point. If too close to a tower or pillar node this method might change the snappedPosition and wayIndex. -
considerEqual
public static boolean considerEqual(double lat, double lon, double lat2, double lon2) -
toString
-