Thanks all for helpful source comments. I can now compare numbers from different sources. This link should contain the newest source: 4.am.pl
Output:
$ ./4.am.pl
Subroutine get_logger redefined at ./4.am.pl line 146.
INFO: ./4.am.pl
INFO: pi is 3.14159265358979
INFO: Bonneville max altitude in feet: 5200
INFO: Boise 43.61 -116.2
INFO: return from the google is 821 meters
INFO: Altitude in feet is 2693.56964
INFO: Difference from max Bonneville elevation is 2506.43036 ft
INFO: USGS elevation is 2697.37 ft
INFO: Percent difference is 0.140990634426756
INFO: distance is 7794.07491881811 miles
INFO: distance is 4656.32531168763 miles
INFO: Percent difference is 50.4039958401085
INFO: ==============
INFO: near sublett 42.3278114 -113.2104084
INFO: return from the google is 1455 meters
INFO: Altitude in feet is 4773.6222
INFO: Difference from max Bonneville elevation is 426.3778 ft
INFO: USGS elevation is 4780.72 ft
INFO: Percent difference is 0.148577470880213
INFO: distance is 175.16979925839 miles
INFO: distance is 175.486511142723 miles
INFO: Percent difference is 0.180639489402675
INFO: ==============
INFO: snowville 41.9655701 -112.7105234
INFO: return from the google is 1384 meters
INFO: Altitude in feet is 4540.68256
INFO: Difference from max Bonneville elevation is 659.31744 ft
INFO: USGS elevation is 4545.24 ft
INFO: Percent difference is 0.100318706656456
INFO: distance is 35.8058824322112 miles
INFO: distance is 35.837188345951 miles
INFO: Percent difference is 0.0873941147406608
INFO: ==============
INFO: juniper 42.152429 -112.9842191
INFO: return from the google is 1577 meters
INFO: Altitude in feet is 5173.88468
INFO: Difference from max Bonneville elevation is 26.1153199999999 ft
INFO: USGS elevation is 5169.2 ft
INFO: Percent difference is 0.0905857419703596
INFO: distance is 19.0729839145012 miles
INFO: distance is 19.0916186594743 miles
INFO: Percent difference is 0.097654599897474
INFO: ==============
$
The first distance is kludged with garbage values, so not too surprised to see 50% error there, but look at how close the values tended to be! I think I might have 3 sig figs. The modified script is approximately:
### Elevation with USGS
use Geo::WebService::Elevation::USGS;
my $eq = Geo::WebService::Elevation::USGS->new();
my $alt =
$eq->elevation( $event->{location}->{lat}, $event->{location}->{lo
+n} )
->{Elevation};
$logger->info("USGS elevation is $alt ft");
### compare values
my $percent = percent_error( $feet, $alt );
$logger->info("Percent difference is $percent");
### home cooked distance
my $d = distance(
$prev_lat, $prev_long,
$event->{location}->{lat},
$event->{location}->{lon}, "M"
);
$logger->info("distance is $d miles");
### distance with GPS::Point
use GPS::Point;
my $gps = GPS::Point->new( lat => $prev_lat, lon => $prev_long );
my $dist =
$gps->distance( $event->{location}->{lat}, $event->{location}->{lo
+n} );
my $feet2 = 3.28084 * $dist;
my $miles = $feet2 / 5280;
#$logger->info("distance is $feet2 feet");
$logger->info("distance is $miles miles");
### compare values
my $percent2 = percent_error( $d, $miles );
$logger->info("Percent difference is $percent2");
Really happy to work up a different source for elevations, and look, I ran into Tom Wyant's software again:
Running Build test for WYANT/Geo-WebService-Elevation-USGS-0.120.tar.g
+z
t/basic.t .. ok
t/elev.t ... # Accessing https://nationalmap.gov/epqs/pqs.php
Cheers,
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.