Finding a point between two geographic locations of lighthouses

Suppose we have two beacons located on both sides of the road. We know their latitude and longitude , where they are located (we consider them as location). We also know the distance in meters between the two beacons (measured using the Haversin Formula). Our device moves between (within the range of these beacons) these two points. Is there any function that will help us calculate our current position based on the distance between two beacons or based on the distance from the device to one beacon? How can I find the location of a device based on this data, or are there any things that will be useful to achieve what I want?

BRIEF: I want to know where the user is between the two beacons , not using the GPS system, but the data that I have from the lighthouse (in this case: the location of Precise Lighthouses, the exact distance from the user to the lighthouse and the exact distance between the two beacons)

As an illustration: ( Filled Black dots are beacons with an imaginary Range , Red dots are some user unknown positions and Green Lines are Known Distances , we also know the latitude and longitude black dots). Based on this data, I want to search for a user's position (Single Red Dot)

enter image description here

note: I checked this question , however, I did not understand why the location returns as int and why time t included there.

+2
source share
2 answers

Here are methods for setting locations and getting the distance from where you are between these two points.

  private Location BeaconLocation1() { Location location = new Location("POINT_LOCATION1"); location.setLatitude(45.0); location.setLongitude(45.0); return location; } private Location BeaconLocation2() { Location location = new Location("POINT_LOCATION2"); location.setLatitude(45.5); location.setLongitude(45.5); return location; } public class MyLocationListener implements LocationListener { public void onLocationChanged(Location location) { Location pointLocation1 = BeaconLocation1(); Location pointLocation2 = BeaconLocation2(); float distance1 = location.distanceTo(pointLocation1); float distance2 = location.distanceTo(pointLocation2); Toast.makeText(MapsActivity.this, "Distance from Point1: "+distance1+" Meters", Toast.LENGTH_LONG).show(); Toast.makeText(MapsActivity.this, "Distance from Point2: "+distance2+" Meters", Toast.LENGTH_LONG).show(); } public void onStatusChanged(String s, int i, Bundle b) { } public void onProviderDisabled(String s) { } public void onProviderEnabled(String s) { } } 

EDIT:

view this message

convert meters to latitude longitude from anywhere

0
source

To focus on your question, there is no one-time formula to do everything but a few to make the process easier. You will have to search around a whole host of math libraries to find them, though.

This is the theory underlying it.

Ok, so we require the latitude and longitude of point 3. I'm going to explain the theory behind it, because the code is just too much for me now.

To do this, we will use the support from one point to another. You can use this link to get this formula: Bearing formula

I assume that we know the distance between the device and each of the individual beacons, otherwise this is not possible if you do not want to use a kind of radar approach to identify this. I can not help it. If we know this, we can construct imaginary circles around two beacons, using the distance from them to the device as their radii.

eg. From the device to the lighthouse - 500 meters. From the device to the lighthouse 2 is 200 M. Draw an imaginary circle around the lighthouse with a radiooid of 500 M and an imaginary circle around the lighthouse with a radius of 200 m.

obviously, we cannot program these circles, it would be too tiring. Therefore, we will use the equation of the circle: (x -h) ^ 2 + (y - k) ^ 2 = r ^ 2.

A quick version of high school shows that h and k are the x and y coordinates of the center of the circle, offset from the Cartesian plain. we will focus our imaginary Cartesian plain at the first point. Now we will analyze the reference point to point two, using the distance from point to, to build a line from 0.0 on our Cartesian plane (point 1) to point 2. Using the tan of our bearing, we get the gradient of the line. Now we will use the cos and sine of our bearing and using the distance of our hypotenuse to obtain the position y and x of beacon 2 relative to beacon 1 on our Cartesian plane. Now we will return these values ​​back to our circle equations:

your first equation will always be: (x -0) ^ 2 + (y - 0) ^ 2 = r ^ 2. Where r is the radius in this example 500M. the second equation is (x -h) ^ 2 + (y - k) ^ 2 = r ^ 2. Where r is the radius in this example 200M. Except now h is your calculated value of x above and y is the calculated value of y above.

Now for a complicated party. We need to find where these circles intersect. From our friends in the exchange of the mathematical stack, I received the formula. Intersection points

Now your circles can have zero 1 or two intersection points based on the position of the devices. If you get two results, you will have to run the whole thing again while the device is moving to see if we are moving closer or further from the centers of the circles. From this we can conclude which side is the correct point, and we can direct a straight line to lighthouse 1 on our Cartesian plain, get the gradient of the line, convert it to a bearing from lighthouse 1, and then rebuild the haversine and bearing formula to obtain the coordinates.

It is not very or simple, but in the end you will get there. This is most likely not the only solution, so feel free to look for others. Good luck.

0
source

All Articles