Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7770337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:23:08+00:00 2026-06-01T16:23:08+00:00

I am writing a location based App and want to get some wisdom on

  • 0

I am writing a location based App and want to get some wisdom on sensible API usage.

What I’ve understood so far is that working with int is more efficient. I’m going to need to store loads of them and do alot of distance calculations.

My app uses a Service that implements LocationListener and I am storing longitude & latitude as int values (micro-degrees) inside an SQL db (via ormlite) calculated thus ::

public static int degreesToMicroDegrees(double degrees){
    return (int)(degrees * 1E6);
}

Sometimes I need to know when I have returned to a particular ‘location’ and as such I fetch the int values back out of the db to compare with the latest location update.

Question is, what is the best way to compare ‘location’ between the int values (where I used to be) and the double values (where I am now) in my latest Location update?

I have searched around for some Math to accomplish the distance calculation and found this ::

public static double distanceBetween(double lat1, double lng1, double lat2, double lng2) {

          double earthRadius = 3958.75; 
          double dLat = Math.toRadians(lat2-lat1); 
          double dLng = Math.toRadians(lng2-lng1); 
          double a = Math.sin(dLat/2) * Math.sin(dLat/2) + 
                   Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * 
                   Math.sin(dLng/2) * Math.sin(dLng/2); 
          double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
          double dist = earthRadius * c; 

          return dist; 
        } 

I have tried passing my int values in like this :: ((double)myIntValue) / 1E6F
The returned distance values are confusing me. If I walk 100m my app sensibly tells me I’ve gone about 100m using Location.distanceTo(myLastLocation). But if I use the method above against my stored int values I get the value zero back.

If anyone can explain the E6 format that would be great.

1E6 is the same as 1000000 ?

Additionally I can see there is this GeoPoint class. I am hesitant to use this as I’m not clear if making vast numbers of calculations on GeoPoints is going to be charged for by Google. There seems to be some noise about charges for use of GoogleMaps APIs and I haven’t been able to find a clear explanation of how that charging works.

All wisdom gratefully received.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:23:09+00:00Added an answer on June 1, 2026 at 4:23 pm

    Just my 2cents:

    1E6 is the same as 1,000,000.

    To convert your int latitude/longitude to a double one, you can just do:

    (double)theLat/1E6;
    

    I also recommend that you use the Location.distanceBetween method of the Location class.


    GeoPoint will not incur any costs for your application. I use it all the time. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing my first location based android app, but got confused about some of
I am writing app, that collects location data, based on GPS. And i have
I'm writing an app that allows you to filter database results based on Location
I am writing a map-based iphone app that will send the current location data
I'm writing an iPhone App that relies on getting the device location. Management have
I'm writing an app that monitors the user's location. I have a CLLocationManager object
I'm building an OpenGL based app - writing in native C/C++. I want to
Writing documentation in html requires some code examples. What to do with characters that
I have a coredata based iphone app and have an Entity that has latitude
I am in the process of writing a web app that includes a reporting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.