Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I have a requirement to perform 2 longitude and latitude operations:

  1. Given a location, determine a rectangular boundary around it for some distance (1 km, for example)
  2. Given a location and a well defined rectangular boundary, determine if a coordinate lies within.

I've come across the Geo packages on CPAN and they look very promising. But, I'm not sure how to put it together. Can someone please kick me down the right path?

Thanks!!
  • Comment on Manipulating Longitude and Latitude Information

Replies are listed 'Best First'.
Re: Manipulating Longitude and Latitude Information
by swampyankee (Parson) on May 16, 2007 at 02:17 UTC

    A spherical polygon is "a closed geometric figure on the surface of a sphere which is formed by the arcs of great circles." (from Spherical Polygon). What I would do -- since there are an infinite number of rectangles of any given side centered on a given point -- is find the intersections of the great circles 1km north, south, east, and west of your point.

    For question 2, try Spheres: Miscellaneous Algorithms. They do mention that it can be rather difficult. If your rectangle is oriented so its sides are exactly east-west and north-south, it's much easier.

    emc

    Insisting on perfect safety is for people who don't have the balls to live in the real world.

    —Mary Shafer, NASA Dryden Flight Research Center
Re: Manipulating Longitude and Latitude Information
by DrHyde (Prior) on May 16, 2007 at 09:31 UTC
    <sniff sniff> I smell homework.

      No, Sir. This is a real life business requirement. It's been a while since I've done homework!!