Thread: How do I create a pair of longitude and latitudes to show a 2 mile radius of a partic

1. Member
Join Date
Feb 2014
Posts
18
Rep Power
0

How do I create 3 pair of longitude and latitudes to show a 2 mile radius of a partic

Out of my depth a little :-) How do I create 3 pairs of longitude and latitudes to create a polygon showing a 2 mile radius of a particular longitude and latitude? in Java Android. I know how to find your current longitude and latitude, but I just can't figure out the above.

My code so far is below:

Java Code:
```    LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double longitude = location.getLongitude();
double latitude = location.getLatitude();```
Last edited by RealSmile; 02-24-2014 at 03:03 PM.

2. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
5,642
Rep Power
9

Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

I don't program Androids but I do not believe the radius is dependent on the longitude or latitude but more on the birds eye height above the earth. In any event from a given height the degree equivalent for a 2 mile radius from your current position should be easy to calculate.

Regards,
Jim

3. Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

a polygon showing a 2 mile radius
Can you explain what you are trying to do? Is it something like this: Given a position on the earth's surface determined by its latitude and longitude are you trying to draw a circle with a 2 mile radius around that position?

4. Member
Join Date
Feb 2014
Posts
18
Rep Power
0

Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

Yes pretty much the above. But I need to do the above using two sets of longitude and latitude corinates to outlin the area. Do you know how to accomplish this?
I know it has something to do with Geofencing and the use of LatLng but further than that I'm still pretty stuck

5. Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

two sets of longitude and latitude corinates to outlin the area
Do those two positions define a box that is supposed to enclose the polygon/circle?

I don't know what GeoFencing is. The LatLng class just holds the lat and long. I've used LatLng objects to position waypoint markers and draw connecting lines for the route between the waypoints.

6. Member
Join Date
Feb 2014
Posts
18
Rep Power
0

Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

Yeah. Here's a link to android's explanation.
https://developer.android.com/traini...eofencing.html

7. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
5,642
Rep Power
9

Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

I would also assume you need to take into account the curvature of the earth.

Regards,
Jim

8. Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

Depends on the radius. Small distances can assume flat earth.

What is it that you are trying to do? Define a collection of LatLng objects that are on a circle of a given radius from a given location? How many objects? How good a circle?
Last edited by Norm; 02-24-2014 at 02:35 AM.

9. Member
Join Date
Feb 2014
Posts
18
Rep Power
0

Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

I'm using an api which allows you to define your own radius, but rather than the user simply entering their location and radius size in miles or kilometers. I need to enter in two longitudes and latitudes, so, to create the radius using a polygon parameter formatted in 2 latlng pairs.

Do you know how I can accomplish the above?

10. Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

I'm not sure what your problem is. Is it determining the distance between two locations? That distance will be used to draw a circle around one of the locations that goes through the other location.

11. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
5,642
Rep Power
9

Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

Originally Posted by Norm
Depends on the radius. Small distances can assume flat earth.
You are correct! (But I wanted to check it out for myself with a little trig).

Regards,
Jim

12. Member
Join Date
Feb 2014
Posts
18
Rep Power
0

Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

Originally Posted by Norm
I'm not sure what your problem is. Is it determining the distance between two locations? That distance will be used to draw a circle around one of the locations that goes through the other location.
The problem is, I don't know how to do this function within java for android. So if you could give me some help that'd be great :-)

13. Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

Sorry, I still don't know what you are trying to do.

What function are you trying to do?

14. Member
Join Date
Feb 2014
Posts
18
Rep Power
0

Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

I feel like I'd be repeating my self but (this is the function I'm trying to achieve)
1. System identifies user location in longitude and latitude (as above)

2. System then utilises user location ( longitude and latitude) to form a radius of 2 miles from user's location by means of a polygon parameter expressed as 2 pairs of longitude and latitude coordinates
Last edited by RealSmile; 02-24-2014 at 01:42 PM.

15. Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

polygon parameter expressed as 2 pairs of longitude and latitude coordinates
That doesn't make sense to me. Are you saying that the polygon will only have 2 points? Two points define a line. I'd think the polygon would have at least a dozen points if it was going to be in the shape of a circle.

If that is not the case, please explain what the two points are and how they are related to the user's location (another point)

16. Member
Join Date
Feb 2014
Posts
18
Rep Power
0

Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

Originally Posted by Norm
That doesn't make sense to me. Are you saying that the polygon will only have 2 points? Two points define a line. I'd think the polygon would have at least a dozen points if it was going to be in the shape of a circle.

If that is not the case, please explain what the two points are and how they are related to the user's location (another point)
I apologise, I've made a mistake. There should actually three pairs of longitude and latitude coordinates to form a radius of 2 miles around the user's location expressed earlier. Hopefully this helps. sorry again :-)

17. Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

Sorry, I don't see what you are trying to do. Three points would define a triangle, not a circle.
A circle is defined by a center point and a radius.

Where would each of the three points be relative to the point that is the user's location?

18. Member
Join Date
Feb 2014
Posts
18
Rep Power
0

Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

After fiddling with the api, I seem to be able to put any number of sets of longitude and latitudes in at once, so to form a radius (Large circle) How do I determine the appropriate set of coordinates to do this. Bearing in mind I'm trying to create a 2 mile radius around the user's location expressed above

19. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
5,642
Rep Power
9

Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

If I were doing this I would consider long/lat as a decimal value representing degrees (which in this case would be xc,yc or center of rotation).
Then figure out the radius equivalent for two miles and rotate thru 2pi, generating your circle's circumference. The increment of your angle controls the
number of points in the circumference.

Regards,
Jim

20. Re: How do I create a pair of longitude and latitudes to show a 2 mile radius of a pa

Are you asking: given a center point, how to determine a large number of points that are on the circumference of a circle centered on that center point and that are the radius distance from the center point?

Page 1 of 2 12 Last

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•