public void calcSnappedPoint ( DistanceCalc distCalc ) { if ( closestEdge == null ) throw new IllegalStateException ( "No closest edge?" ) ; if ( snappedPoint != null ) throw new IllegalStateException ( "Calculate snapped point only once" ) ; PointList fullPL = getClosestEdge ( ) . fetchWayGeometry ( 3 ) ; double tmpLat = fullPL . getLatitude ( wayIndex ) ; double tmpLon = fullPL . getLongitude ( wayIndex ) ; double tmpEle = fullPL . getElevation ( wayIndex ) ; if ( snappedPosition != Position . EDGE ) { snappedPoint = new GHPoint3D ( tmpLat , tmpLon , tmpEle ) ; return ; } double queryLat = getQueryPoint ( ) . lat , queryLon = getQueryPoint ( ) . lon ; double adjLat = fullPL . getLatitude ( wayIndex + 1 ) , adjLon = fullPL . getLongitude ( wayIndex + 1 ) ; if ( distCalc . validEdgeDistance ( queryLat , queryLon , tmpLat , tmpLon , adjLat , adjLon ) ) { GHPoint tmpPoint = distCalc . calcCrossingPointToEdge ( queryLat , queryLon , tmpLat , tmpLon , adjLat , adjLon ) ; double adjEle = fullPL . getElevation ( wayIndex + 1 ) ; snappedPoint = new GHPoint3D ( tmpPoint . lat , tmpPoint . lon , ( tmpEle + adjEle ) / 2 ) ; } else // outside of edge boundaries snappedPoint = new GHPoint3D ( tmpLat , tmpLon , tmpEle ) ; }
Calculates the closet point on the edge from the query point .