GPS perl.

Joined
Oct 4, 2014
Messages
5
Reaction score
0
Hi

Please give a link or advice for writing codes in Perl to show GPS coordinates from a device with built-in gps chipset such as Samsung tablet 4 7" sm-t230.

Thank you.
 
Last edited:
Example: How to get these codes work on cgi:


#!/usr/bin/perl
use GPS::NMEA;

my $gps = GPS::NMEA->new(Port => '/dev/cuaa0',
# or COM5: or /dev/ttyS0
Baud => 4800);
while(1) {
my($ns,$lat,$ew,$lon) = $gps->get_position;
print "($ns,$lat,$ew,$lon)\n";
}
 
Last edited:
Another example:

use strict;
use LWP::Simple; # from CPAN
use JSON qw( decode_json ); # from CPAN
sub getLatLong($){ my ($address) = @_;
my $format = "json"; #can also to 'xml'
my $geocodeapi = "https://maps.googleapis.com/maps/api/geocode/";
my $url = $genocideapi.$format."?sensor=false&address=. $address;
my $json = get($url);
my $d_json = decode_json( $json );
my $lat = $d_json->{results}->[0]->{geometry}->{location}->{lat}; my $lng = $d_json->{results}->[0]->{geometry}->{location}->{lng};
return ($lat, $lng); }
 

Members online

Back
Top