On Wed, Mar 16, 2011 at 5:12 PM, Bryan Stevenson wrote:
> I'm wondering if anyone has any advice on performing a task that
> involves determining if a given lat/long is within a given oddly shaped
> (not a simple rectangle) area/box?

Where do the point and the polygon originate and in which way are they
described? In most cases I have dealt with the point was based on user
input and the polygon was in some server side dataset. In that case it
is just a matter of storing the polygon in a proper format like WKB or
whatever geometric datatype your database offers and using the API's
or SQL operators provided to do the comparison.


> I would assume the hard part is defining the boundaries of an irregular
> shaped box, but once defined the check to see if the co-ordinates are
> within it is probably more straightforward.

Typically you define your shapes by the coordinates of the series of
points that make up the edge. Then you first get a simple (indexable
in a proper database) comparison to see if your point is a potential
match (between min/max of long/lat). Followed by more complex math to
see if it is a proper match. For instance a crescent shape has lots of
points between the minimum and maximum that still don't overlap. The
latter comparison is something you definitely don't want to implement
yourself.

Jochem


-- 
Jochem van Dieten
http://jochem.vandieten.net/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:343086
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to