public static double orthogonalDistance ( GeoPoint point , GeoPoint lineStart , GeoPoint lineEnd ) { double area = Math . abs ( ( lineStart . getLatitude ( ) * lineEnd . getLongitude ( ) + lineEnd . getLatitude ( ) * point . getLongitude ( ) + point . getLatitude ( ) * lineStart . getLongitude ( ) - lineEnd . getLatitude ( ) * lineStart . getLongitude ( ) - point . getLatitude ( ) * lineEnd . getLongitude ( ) - lineStart . getLatitude ( ) * point . getLongitude ( ) ) / 2.0 ) ; double bottom = Math . hypot ( lineStart . getLatitude ( ) - lineEnd . getLatitude ( ) , lineStart . getLongitude ( ) - lineEnd . getLongitude ( ) ) ; return ( area / bottom * 2.0 ) ; }
Calculate the orthogonal distance from the line joining the lineStart and lineEnd points to point