开发者

Android: Location.distanceBetween units and emulator not sending coordinates properly

Hy everyone, I have two questions

1) I have not been able to find out in which units Location.distanceBetween receivs the latitude and longitude. Is it degrees or microdegrees? Whats the unit for the distance returned? Sorry for t开发者_Go百科his noob questions but I have not been able to find anything on the documentation.

2) In windows XP using Eclipse 3.3.2. Emulator does not send coordinates properly. Either it by hand or by loading a gpx file the locationListener is not invoked. This same code I have tried it in Ubuntu and works fine. Does someone know how can I solve this? In the office there is no linux installed and I can take my personal laptop.

Thanks a lot in advanced!


1) From android source:

public static void distanceBetween(double startLatitude, double startLongitude,
    double endLatitude, double endLongitude, float[] results) {
    if (results == null || results.length < 1) {
        throw new IllegalArgumentException("results is null or has length < 1");
    }
    computeDistanceAndBearing(startLatitude, startLongitude,
        endLatitude, endLongitude, results);
}

And inside computeDistanceAndBearing there is comment that says:

// Based on http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf
// using the "Inverse Formula" (section 4)

I would check there

2) Go to:

  • Settings
  • Applications
  • Development
  • Check if "Allow mock locations" is on.


I had problems with the emulator not getting locations from ddms and it turned out to be because I had an non-english locale which appears to screw it up. You can try adding "-Duser.language=en" to the start parameters for java in the ddms start script and see if it helps. The bug is here

Oh and I don't know the input units for lat/long but the resulting float is in metres according to the api docs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜