I have a world map with world events (like volcanoes, earthquakes, hurricanes, etc.) mapped on it. I also have buildings (like the Empire State Building) mapped on it. I can determine through simple math if an event is within N miles of a building. I've done this in Perl and translated the math to a mysql function, since these calculations are done at the database level.
But now I have a more complex sort of "building" to map. This isn't a building in a single place, it's essentially a path, like for a pipeline. The pipeline is defined by its vertices: every place the pipeline changes direction is a vertex (obviously).
I want to determine now if an event is within N miles of this "pipeline". However, this is more than just checking each individual vertex of the pipeline, because it is possible for the event to be too far from a vertex to register a hit, yet close enough to a line drawn between the two vertices (which is the actual pipeline).
I sort of know the math for this situation... I need to test for a point (X0,Y0) on the line from (X1,Y1) to (X2,Y2) -- that's the pipeline -- that is on the perimeter of a circle of radius R from point (X3,Y3) -- that's the event. But I'm not sure I know how to convert that into lat/lng math for use in mysql. Any pointers?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||