Class Snap

java.lang.Object
com.graphhopper.storage.index.Snap

public class Snap extends Object
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
  • Field Details

  • 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 also QueryGraph.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

      public Snap.Position getSnappedPosition()
      Returns:
      0 if on edge. 1 if on pillar node and 2 if on tower node.
    • setSnappedPosition

      public void setSnappedPosition(Snap.Position pos)
    • isValid

      public boolean isValid()
      Returns:
      true if a closest node was found
    • getClosestEdge

      public EdgeIteratorState getClosestEdge()
    • setClosestEdge

      public void setClosestEdge(EdgeIteratorState edge)
    • getQueryPoint

      public GHPoint getQueryPoint()
    • getSnappedPoint

      public GHPoint3D 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

      public void setSnappedPoint(GHPoint3D point)
    • calcSnappedPoint

      public void calcSnappedPoint(DistanceCalc distCalc)
      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

      public String toString()
      Overrides:
      toString in class Object