how to find distance between two areas in android - java

hi all
i want to fin out distance between two places. if i go from one place to another place by street by street the distance is vary and suppose i walk within a street the latitude and longitude may not be changed. so these method may not help me. is there any other way for calculating distance for my requirement it whould be great to me. please help me.

Based on what you're attempting to do I would suggest figuring out if you can implement a pedometer (walking distance meter) using the accelerometer, combine that with the coarse location API and/or the fine location API and the compass you should be able to implement a pretty good location logger.
Other than that I'm not sure what you're trying to do.

Related

Multi-points Trilateration to be used with beacon data on Android

I've been struggling for a while with this, I'm currently using Estimote Beacon on Android and I'm collecting their RSSI and TxPower to calculate their range. Once I got this data and I know their position (latitude, longitude, altitude), I need to calculate my rough position for an Indoor Location purpose.
All the solution provided only are either for three single points or doesn't work. There must be an existing Java Solution somewhere since it's a common problem.
Now I know that this was asked before but no answer really helped me in my case. Here is a resume of some of them:
- Solution using three points only:
Trilateration Method Android Java
Multi-point trilateration algorithm in Java
Trilateration Method Android Java
- Solution I've tried but gets me a wrong result
Trilateration Java Algorithm
Another side question If I might ask, What unit of measure should I use for the distance when I'm calculating this? I though it would be the same result whatever distance unit I was using but It turned out the result vary a lot depending if I plug meter or kilometer...

Distance between 2 locations

I need to be able to work out the distance between 2 houses in my local area, unfortunately I can't find anything that seems to work. The I've looked at Google Maps Java Engine, however that will be disabled at the start of next year, so is out of the question.
I need to be able to take an input of:
"1 Blue Road"
and work out the distance to, by road and path to, in meters (or smallest measurements possible", to
"2 Red Road"
A preference is that it works offline, using a file of the local area as I am expecting to do lots of queries to it, so preferably don't want query limits. This is because I am doing this for a school project, so I need to be able to create a network of all the houses and the distances between them, as I need to be able to apply a shortest path algorithm to it, by myself, to prove that the program is complex. I'm not bothered about efficiency of this program.
I also need a little help on setting up the "system" because I've seen files before that help you find the distance between 2 locations, but the problem is that I've not been able to find a tutorial of how to set up and use.

calculate accumulated distance using GPS in android

I am a new user and is new to android programming.
I am trying to creating a android application that calculate distance a user traveled using a GPS. one of the examples I can think is like a treadmill where it shows the accumulated distance. except the user will be moving around and using a gps to see how long he walked/run.
i can activate a gps, using LocationManager and LocationListener to get a longitude and latitude. but i do not know how to go from there
all my research shows how to calculate distance traveled between 2 points, A to B in a line,shortest distance. but i wanted to have a real-time accumulated distance no matter in which direction the user is going. or how fast.
i do not understand how the logic/math behind the calculation so it is hard for me to come up with a solution. the get.DistanceTo and DistanceBetween also calculate distance in a linear line right?
i also heard something about a accelerometer to use with a GPS. but based on my research so far(not too in depth) it also shows a single location, but i also do not know how to calculate distance from there. or how does it works with GPS
does i have to use longitude and latitude or others?
i'm quite weak in programming but this is a task i have to complete. Thanks
The Google Distance Matrix API
Can't take credit for the answer, I got it from Another post
I would stick to the GPS data and not worry with the accelerometer. Then you would have to record the position in defined intervals and just add the distance to the last point every time you check. The closer you want to get to the real distance the more frequently you have to check. You could then make the interval dynamic e.g. check less often if you go faster.

Android Algorithm for find all Geopoints within a given distance

In my naive beginning Android mind I thought the way to do this would be to loop through each of the objects checking if proximity falls within X range and if so, include the object. This is being done with Google Maps and GeoPoints.
That said, I know this is probably the slowest way possibly. I did a search for Android Proxmity algorithm's and did not get much really. What I am looking for is best options with regard to this the more efficiently.
Are there any libraries I have not been able to find?
If not, should I load these Location objects into SQL then go from there or keep them in a JSONArray?
Once I establish my best datastructure, what is he best method to find all Locations located with X miles of user?
I am not asking for cut and paste code, rather the best method to this efficiently. Then, I can stumble through the code :)
My first gut feeling is to group the Locations by regions but I'm not exactly sure how to do this.
I could potentially have tens of thousands of datapoints.
Any help in simply heading in the right direction is greatly appreciated.
As a side note, I reach this juncture after discovering that a remote API I had been using was.. well.. just PLAIN WRONG and ommiting datapoints from my proximity search. I also realized that if just placed on the datapoints on the phone, then I could allow the user to run the App without internet connection, and only GPS and this would be a HUGE plus. So, with all setbacks come opportunnities!
The answer depends on the representation of the GeoPoints: If these are not sorted you need to scan all of them (this is done in linear time, sorting wrt. distance or clustering will be more expensive). Use Location.distanceTo(Location) or Location.distanceBetween(float, float, float, float, float[]) to calculate the distances.
If the GeoPoints were sorted wrt. distance to your position this task can be done much more efficiently, but since the supplier does not know your position, I assume that this cannot be done.
If the GeoPoints are clustered, i.e. if you have a set of clusters with some center and a radius select each cluster where the distance from your position to the cluster's center is within the limit plus the radius. For these clusters you need to check each GeoPoint contained in the cluster (some of them are possibly farther away from your position than the limit allows). Alternatively you might accept the error and include all points of the cluster (if the radius is relatively small I would recommend this).

Calculate real time distance traveled using google maps

There is a requirement to find the real time distance traveled using google maps. This should be calculated by the phone app itself. When I mean real time, I mean for example if the user is traveling to point A, the user can get to the point in many ways, what I want to do is calculate the total distance the user has traveled real time and not just assume and calculate the distance between the two points (which would not give the correct answer).
I googled around for this problem but could not find any method in doing so.
I personally thought of storing the longitude and latitude on the phone in a list and after the user reaches the destination the distance is caluclated using these points. However this means that I have to decide the interval in which these points are stored (every 1 min or so), which would mean that I would place location points in the list even though the user was actually still on the same road, which is quite unnecessary. Unless if anyone knows how to store the points at the appropriate time or some other solution
I am well more or less stumped on this problem, any help is really appreciated
The mobile platform is Android
Thanks,
MilindaD
I think the best solution is to save the position each X seconds, and then calculate the total distance iterating between them, and to get the time, you just need to see the diference between the last point and the first one.
This is how gps tracking apps work.
Hope this helps ;)
I did it once and it is fairly simple. Use a service with a LocationListener. On every onLocationChanged() save the current Location, At the end you can calculate with Location.distanceBetween() all distances between these saved Locations.
Please keep in mind that it becomes more accurate with faster tracking. For a walk you need less updates than driving a fast car. This can be set with minDistance and/or minTime in LocationManager.requestLocationUpdates().
you could try takeing the start point (IIRC their Long and Lat) then the end point and working out the euclidean distance between the two (see http://en.wikipedia.org/wiki/Euclidean_distance ).
I guess you what a better reloution then two point throgh, so take a third (or more) reading and work out A->B then add B->C.
Repeat for the resaloution you need.
to get the time of the journey. start a clock and stop it at the end (again you could take intermittent points if you wanted)

Categories

Resources