Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^4: Moon phase on historical events

by bliako (Monsignor)
on Oct 11, 2021 at 11:51 UTC ( [id://11137415]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Moon phase on historical events
in thread Moon phase on historical events

Great additions Aldebaran!

DateTime can do date arithmetic as simply as:

my $dt = DateTime->new( year => 2021, month => 4, day => 5, hour => 2, time_zone => 'Africa/Nairobi', ); # or, create a DateTime object from an ISO timestring my $isostr = '2021-10-11T11:13:57'; my $dt = DateTime::Format::ISO8601->parse_datetime($isostr); # add a second to what $dt currently holds $dt->add(seconds => 1);

Regarding your other questions, I have no clue about celestial mechanics. Nonetheless I have whipped up a Perl sub to get you the elevation given coordinates. It uses a site which I am not sure if they would like people using their services in this way. So with that in mind:

# usage: # my $elevation = get_elevation_from_coordinates(15.6325, 38.245833, 0 +); sub get_elevation_from_coordinates { my ($lat, $lon, $debug) = @_; $debug //= 0; my $ua = LWP::UserAgent->new( agent => 'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100 +101 Firefox/78.0', ); my $response; my $payload = 'latitude='.$lat .'&longitude='.$lon .'&application_max_assets_mtime=1559625591' ; my $payloadlen = length($payload); # this request was translated from Curl command-line # by [Corion]'s https://corion.net/curl2lwp.psgi my $req = HTTP::Request->new( 'POST' => 'https://www.mapcoordinates.net/admin/component/edit +/Vpc_MapCoordinates_Advanced_GoogleMapCoords_Component/Component/json +-get-elevation', [ 'Connection' => 'keep-alive', 'Accept' => '*/*', 'Accept-Encoding' => 'gzip, x-gzip, deflate, x-bzip2, bzip2', 'Accept-Language' => 'en-US,en;q=0.5', # 'Host' => 'www.mapcoordinates.net:443', 'Referer' => 'https://www.mapcoordinates.net/en', 'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) +Gecko/20100101 Firefox/78.0', 'Content-Length' => $payloadlen, 'Content-Type' => 'application/x-www-form-urlencoded; charse +t=UTF-8', 'DNT' => '1', 'Origin' => 'https://www.mapcoordinates.net', 'X-Requested-With' => 'XMLHttpRequest' ], $payload ); die "call to HTTP::Request has failed" unless $req; if( $debug > 0 ){ print "$0 : $payload\n$0 : sending above payload +, of $payloadlen bytes...\n" } $response = $ua->request($req); die "Error fetching: ".$response->status_line unless $response->is_success; my $content = $response->decoded_content; my $data = Data::Roundtrip::json2perl($content); die "failed to parse received data:\n$content\n" unless exists $data->{'elevation'}; return $data->{'elevation'}; }

bw, bliako

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11137415]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-26 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found