Currently I am working on writing a Perl Mod that will calculate the elevation of a specific point. The reason why I am doing this is, I don't have the cash to throw down on a DGPS unit, all I can afford is just your consumer end GPS models. The problem with this is even though Selective Avaliablity was removed by Clinton, my altitude reading are not very accurate. This is due largely from the fact that it takes at least 4 known points to calculate your altitude, being in tree cover can break the signal for just a split second, causing errors because of the 3 sec latency to the sat. Also, moisture in the tops of trees can have a big impact on the results as well. I would like a more percise reading because I would like to start creating elevation profiles of my hikes (Planning on climbing ~20 fourteeners in CO this summer).
My plan is to take the SDTS data (read Coordinate for more info.) from the USGS and calculate each specific waypoint of my GPS data, and find which 4 known coordinates are closest to my current point. Once I have these points I will then be able to get a pretty go estimate of what my specific altitude is.
This Mod is going to tie into another Mod that I am currently working on called Convert::SDTS which dynamically find the known quadrant the data resides in, by looking through the USGS data tables, I am also using Coordinate to figure out which USGS file I exactly need to grab.
My question is there a better way to write the following snippet of code?
@nw=qw(0 30); #North West corner
@ne=qw(30 30); #North East corner
@se=qw(30 0); #South East corner
@sw=qw(0 0); #South West corner
@find=qw(10 5); #Point I am trying to find
# my current logic to establish if my point
# does indeed exist inside my four defined
# points.
if ((($find[0]<($nw[0]<=$sw[0]?$nw[0]:$sw[0])) or #inside of west?
($find[0]>($ne[0]>=$se[0]?$ne[0]:$se[0])))or #inside of east?
(($find[1]<($sw[1]<=$se[1]?$sw[1]:$se[1])) or #inside of south
+?
($find[1]>($ne[1]>=$nw[1]?$ne[1]:$nw[1])))) { #inside of north
+?
die "data is outside of the quadrant\n";
}
This just seems very clumbsy, and I am sure I am missing something easy to clean this up a bit. Please help me out all wise ones.
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:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.