#!/usr/bin/perl
#
#	Copyright 2016 (c) Shin-ichi Nagamura.
#	All rights reserved.
#
#	$Id: getGeoLocationGoogle 92 2016-09-24 11:48:19Z core $
#


use	utf8 ;
use	strict ;
use	warnings ;

use	kuon ;
use	kuon::GeoLocation ;
use	kuon::GeoLocation::google ;

use	Getopt::Long ;

binmode	STDOUT,	":utf8" ;
binmode	STDERR,	":utf8" ;


# ----- options -----
my	$opt_help				= 0 ;

my	%options	= (
		"debug"				=> \$kuon::opt_dbg,
		"verbose"			=> \$kuon::opt_msg,
		"help"				=> \$opt_help,
	) ;


sub		usage( $ )
{
	my	$rc	= shift ;

	printf( "usage: getGeoLocationGoogle [OPTIONS...]\n" ) ;
	printf( "--debug     for debugging\n" ) ;
	printf( "--verbose   verbose mode\n" ) ;
	printf( "--help      show this message\n" ) ;
	exit( $rc ) ;
}


sub		main()
{
	# ----- read options -----
	Getopt::Long::Configure( "bundling" ) ;
	&usage( 1 )		unless( GetOptions( %options )) ;
	&usage( 0 )		if( $opt_help ) ;
	&usage( 1 )		if( $#ARGV != -1 ) ;

	my	$google			= kuon::GeoLocation::google->new( "AIzaSyDqE086atJ4rbv9NCEmctD9FgCd3G8MaRw" ) ;
	my	$geoLocation	= $google->get() ;
#	&kuon::dbg( "geoLocation=" ) ;	print STDERR Dumper $geoLocation ;

	printf( "latlng=( %f,%f ), accuracy=%f\n", $geoLocation->{lat}, $geoLocation->{lng}, $geoLocation->{accuracy} ) ;

	return( 0 ) ;
}


exit( main()) ;
