Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How to know person is inside or outside of given pairs of lat long.

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am stuck up at one problem. I have few pairs of lat long which is creating closed boundary/fence on a map. Now I want to know whether person is inside that fence or not ?
How can I know that ?

Is there any api available or any algorithm is there or not ?
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You would have to first get the lat/long of the person's location. After that it is simple arithmetic.
 
Hardik Trivedi
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Peter Johnson wrote:You would have to first get the lat/long of the person's location. After that it is simple arithmetic.



Yea I have person's current location. I would like to know about the algorithm
 
Saloon Keeper
Posts: 7233
169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're looking for something like this: http://stackoverflow.com/questions/4901959/find-if-a-point-is-inside-a-convex-hull-for-a-set-of-points-without-computing-th
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hardik Trivedi wrote:Yea I have person's current location. I would like to know about the algorithm


You're kidding, right??? Have you tried visualizing the situation using example long/lats for the box, and log/lat for a user who is inside and not inside the box? Draw it out on a piece of paper if you need to. Or take a simpler case with a simple graph using X and Y coordinates using vertical and horizontal lines and the person being a point inside or outside the box. Of course, this ignores the possibility that the box encompasses either the north or the south pole, then the algorithm gets more complex.
 
Sheriff
Posts: 26963
84
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that choosing the word "box" was unfortunate, as it strongly suggests a rectangle. However the original post said

I have few pairs of lat long which is creating closed boundary/fence on a map.



Note that "few" is not necessarily "two". So there's some kind of polygon involved but it's not necessarily a rectangle.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The title says "given pairs of lat long", so I assumed that Hardik had two longitudes and two latitudes, which then described a rectangle (or at least, as close to a rectangle that you can be on a sphere). Of course, if that is not what Hardik wanted, then I guess my comments don't really help!
 
reply
    Bookmark Topic Watch Topic
  • New Topic