Page 1 of 2 12 LastLast
Results 1 to 20 of 29
  1. #1
    RealSmile is offline Member
    Join Date
    Feb 2014
    Posts
    18
    Rep Power
    0

    Question 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. #2
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,810
    Rep Power
    5

    Default 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
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default 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?
    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    RealSmile is offline Member
    Join Date
    Feb 2014
    Posts
    18
    Rep Power
    0

    Default 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. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default 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.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    RealSmile is offline Member
    Join Date
    Feb 2014
    Posts
    18
    Rep Power
    0

    Default 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. #7
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,810
    Rep Power
    5

    Default 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
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default 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.
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    RealSmile is offline Member
    Join Date
    Feb 2014
    Posts
    18
    Rep Power
    0

    Default 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. #10
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default 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.
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,810
    Rep Power
    5

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

    Quote Originally Posted by Norm View Post
    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
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  12. #12
    RealSmile is offline Member
    Join Date
    Feb 2014
    Posts
    18
    Rep Power
    0

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

    Quote Originally Posted by Norm View Post
    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. #13
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default 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?
    If you don't understand my response, don't ignore it, ask a question.

  14. #14
    RealSmile is offline Member
    Join Date
    Feb 2014
    Posts
    18
    Rep Power
    0

    Default 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. #15
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default 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)
    If you don't understand my response, don't ignore it, ask a question.

  16. #16
    RealSmile is offline Member
    Join Date
    Feb 2014
    Posts
    18
    Rep Power
    0

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

    Quote Originally Posted by Norm View Post
    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. #17
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default 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?
    If you don't understand my response, don't ignore it, ask a question.

  18. #18
    RealSmile is offline Member
    Join Date
    Feb 2014
    Posts
    18
    Rep Power
    0

    Default 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. #19
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,810
    Rep Power
    5

    Default 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
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  20. #20
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,616
    Rep Power
    25

    Default 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?
    If you don't understand my response, don't ignore it, ask a question.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 11
    Last Post: 01-01-2014, 09:24 PM
  2. Replies: 0
    Last Post: 01-01-2014, 05:47 PM
  3. how can i create a string that show what key the user pressed?
    By I Lost My Name! in forum New To Java
    Replies: 2
    Last Post: 12-31-2013, 02:32 AM
  4. Convert XL data in to latitude longitude format?
    By suresh.somepalli in forum Android
    Replies: 4
    Last Post: 11-01-2012, 03:26 PM

Posting Permissions

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