What are the latitude and longitude of a circle? - android

In Android, if I have a circle's radius and center value, how could I measure the latitude and longitude of about 1 km periphery of that circle?

Horizontal = x-axis = Longitude
Vertical = y-axis = Latitude

Latitude and longitude are terms necessary to define a position on a sphere, where two angles are necessary. These terms have no relevance to a circle, which exists only in one plane.

This is not an easy problem to solve as the distance between each latitude and longitude varies depending upon where on the globe you are (I'm sure some maths boffin could do it, but it is beyond me). For instance at the north and south pole one degree longitude measures no distance at all, but at the equator one degree can be several kilometers. If however your search only relates to a small are of the globe, then a you can make a reasonable approximation by using 1km = x degrees where x is the correct value where you are.

Terms "circle", "radius" implies a 2D flat plane geometry whereas "latitude", "longitude" implies a geographical coordinates on a 3D ellipsoid.
Putting these problems asides, let's assume, in fact that your "circle" is a point on the surface of our Earth and, the "radius" is a distance from this point. This will correct your terms so they define a 3D problem.
If a projection is given. Then we can specify the "center" in planar geometry coordinates (X, Y). We can specify all points distance "R" in geometry coordinates as (X + R * cos(phi), Y + r * sin(phi)) then we can use the projection to convert the geometry coordinates from planar to geographic i.e. longitude, latitude. The problem is 1000s of projections exists and not all a valid across the entire Earth.
Alternatively, you can define your 3D ellipsoid in 3D space using (X, Y, Z) coordinates. Then the wording of your problem must change. The "circle" because a sphere whose point is on the surface of the ellipsoid and the "radius" is the radius of the sphere. To compute all points distance "R" from the sphere you will need to intersect the sphere with the ellipsoid using trigonometry. After you have done this, you can convert the resultant 3D coordinates back to longitude, latitude based on the definition of your ellipsoid.

Related

what is the latitude longitude relation with the Poles(North, South, East, West)?

I am trying to Understand that What happens to the Latitude longitude when moving to North or south or east or West.
Suppose My current GPS coordinates are;
Latitude = 33.659832 Longitude = 72.345678
Now what will be New Latitude/Longitude 30 METERS to the North of my position also tell me towards south, east and west direction.
Please be specific thanks
Latitude is related to South -> North
If you move North, the latitude increases, if moving south it decreases.
Longitude is related to West -> East
If you move East, the longitude increases until 180 and when you cross that datum limit it jumps to -180.
If you want to calculate a new coordinate by offset meters and direction,
you find code here at stackoverflow.
To play with coordinates you can use http://www.geomidpoint.com/destination/
where you enter the coordinate and the offset in km, and the compass direction in degrees.
The calculation is done either using
complex spherical formulas for calculation of big distances > 1km - 10km or
using school mathematics (Polar coordinates (r, phi) once you have
converted the lat, lon to cartesian space, e.g using a
equirectangular projection. That is suitable only for smaller distances less than about 10km

How do you find relative bearing between two points?

double computeHeading(double latitude1, double longitude1, double latitude2, double longitude2)
{
double degToRad = PI / 180.0;
double phi1 = latitude1*degToRad;
double phi2 = latitude2*degToRad;
double lam1 = longitude1*degToRad;
double lam2 = longitude2*degToRad;
double x,y;
x = cos(phi2) * sin(lam2-lam1);
printf("X is %lf\n", x);
y = cos(phi1) * sin(phi2) - sin(phi1) * cos(phi2) * cos(lam2-lam1);
printf("Y is %lf\n", y);
return atan2(x,y)*180/PI;
}
I am using the above function to determine the true bearing from North between two geographic coordinates.
I'm currently developing a small navigation widget which uses GPS data from Android sensors. The widget has an arrow facing towards a point away from the device's current location. The arrow's direction changes with the device's current location and azimuth to always face the distant point.
Here is a scenario:
I'm at a location, facing north, and another location has a bearing of 300 degrees(somewhat northwest of me). If I face towards south, without moving, my relative bearing to the distant location should be 120 degrees.
How can I find the relative bearing with accounting for the facing direction (azimuth)?
There are a couple of ways you can work this out. The first, which is what you appear to be doing, assumes the earth is spherical. Relative bearings are calculated using Haversine formulation for great circle navigation. Given starting and ending points, this formulation finds the great circle passing through the two points. From this an initial bearing can be calculated. This great circle route is the shortest route between the two points, but suffers from the problem the bearing, in general, will not be constant along the route. Also, except under some very specific cases, the reverse bearing does not behave as you seem to expect and if you want to determine it in general, you will have to perform another calculation reversing the starting and ending points.
Another method you could use is the Rhumb line formulation. In this case, the bearing between the starting point and ending point is constant and would allow you to use the relation you have for the reverse course if you would like. Since this will in general differ from the great circle distance, following Rhumb lines will not result in the shortest path between the two points, but it does simplify the navigation by holding the course constant.
Both of these approaches are described in detail at Calculate distance, bearing and more between Latitude/Longitude points
Another formulation for great circle navigation which uses a more accurate representation of the earth's shape, an oblate spheriod, which is a special type of ellipsoid, is attributed to Vincenty with additional enhancements provided by Karney. In these cases, the formulation is quite a bit more complicated and is probably overkill for most applications, and performance is quite a bit worse than the Haversine formulations above. But these formulations provide much better accuracy if you need it.
Update:
Based on the comment below, the main issue is one of figuring out how far to turn. This will simply be the angle between the normals of the plane containing the great circles for the current heading and the desired heading. To get the normal for the plane on the current heading, you need your current location L and a point some distance away on the current heading, C. The normal is just V = L×C. To compute the normal for the plane containing the great circle along the desired heading, you only need to know a point along the desired route, which you already have in the form of your destination point, which we call D. You can then find the normal by U = L×D. The angle between them is given by θ = acos((U∙V)/(|U||V|)).
In order to find L, C and D you must convert the Latitude, Longitude, Altitude (LLA) coordinates into Earth Centered, Earth Fixed (ECEF) coordinates.

Map v2 convert distance to pixels

I have been searching but I couldn't find it. I am using google map v2. Is there any way I can convert distance ( meters) to pixels on my screen? I need the pixels equivalent of the distance. I have the distance and I have the zoom level.
Any help is appreciated.
If I understand correctly, you have a MapFragment on your screen showing a map. You know the distance in meters between 2 points on the map that are shown on the screen and you want to calculate the distance between those two points in pixels. If you know the LatLng location of the two points, you can use the Projection class like this:
Point point1 = map.getProjection().toScreenLocation(latLng1);
Point point2 = map.getProjection().toScreenLocation(latLng2);
and then you just need to use the distance mathematic formula:

Android position, Longitude (min, max), Latitude (min, max)

I have a little problem using Android.
I have my GPS position, clearly latitude and longitude, and a ray of search in meters (for example 100 meters), ok?
Imagin my position at center of the circle made by ray, I would know how to obtain on Android the:
topLeft Latitude
topLeft Longitude
bottomLeft Latitude
bottomLeft Longitude
of the rectangle that inscribes the circle.
Thank's in advance.
1) Convert center lat long to cartesisan x,y in meters:
(lat lon are on a sphere, x,y is a flat map then you can continue with school mathematics
2) use polar coordinates formula to create the 4 corner points
the first corner has angle 45 degrees, and r = 100m
second corner of the square has angle 45 + 90 degrees
3) convert back the 4 cartesian meter coordinates to lat,lon
a bit more detailed here
How to find a set of lat/long pairs surrounding a 5 miles radius of a certain location
and see my answer here
PHP: How to create a Geo-Fence(bounding Box) using the Distance from a set of Coords

Mapping on a image programmatically

Client given me a particular area map image. Here I need to get the longitude and latitude of the location at the Touch point on the image.
Is there any way I can work on this issue. To get the location of touch point on the image programmatically.
You can really only do this with any accuracy on a MapView, where you can use the methods
GeoPoint fromPixels(int x,
int y)
Create a new GeoPoint from pixel coordinates relative to the top-left
of the MapView that provided this PixelConverter.
and
toPixels
android.graphics.Point toPixels(GeoPoint in,
android.graphics.Point out)
Converts the given GeoPoint to onscreen pixel coordinates, relative to
the top-left of the MapView that provided this Projection.
to transform lat/on to screen coordinates.
If it's a plain old .png the, as long as the view covers a small area (a few square miles only), you could interpolate the lat/lon at the corners to get an approximate value for the touch point. If it was a whole country, then you would have to apply a coordinate transformation to map from a flat Mercator projection to a curved surface.

Categories

Resources