-1

How to find the distance between two locations on android ecillipse project &php .the project is based on online good transport system .The fare of the carrier needed to be found out so there is a need of finding distance between source & destination .Harversine formula was implemented for finding the shortest vehicle in the region

Suraj Makhija
  • 1,376
  • 8
  • 16

2 Answers2

0
float[] results = new float[1];
Location.distanceBetween(source.latitude, source.longitude,
                    destination.latitude, destination.longitude,
                    results);

Computes the approximate distance in meters between two locations, and optionally the initial and final bearings of the shortest path between them. Distance and bearing are defined using the WGS84 ellipsoid. The computed distance is stored in results[0]. If results has length 2 or greater, the initial bearing is stored in results[1]. If results has length 3 or greater, the final bearing is stored in results[2].

  @param startLatitude the starting latitude
  @param startLongitude the starting longitude
  @param endLatitude the ending latitude
  @param endLongitude the ending longitude
  @param results an array of floats to hold the results

  @throws IllegalArgumentException if results is null or has length < 1
S Haque
  • 6,881
  • 5
  • 29
  • 35
0

Try this code

double _distance = Location.distanceBetween(
                 _firstLatitude,
                 _firstLongitude,
                 _secondLatitude,
                 _secondLongitude,
                 _results);
deejay
  • 572
  • 4
  • 18