NAME
Location::GeoTool - Perl extension for Geometry processing
SYNOPSIS
use Location::GeoTool;
# New constructor (Options can be set)
my $oGeo = Location::GeoTool->new({changeMyself => 0,enableWantarray => 0});
$oGeo->set_coord('35.39.24.491','139.40.10.478','tokyo','gpsone');
# Old constructor
my $oGeo = Location::GeoTool->create_coord('35.39.24.491','139.40.10.478','tokyo','gpsone');
my @mapion = $oGeo->format_mapion->array;
# => ("35/39/24.491","139/40/10.478")
my $oGeoW = $oGeo->datum_wgs84;
my @wgs84 = ($oGeoW->lat,$oGeoW->long);
# => ("35.39.36.145","139.39.58.871")
my @degree_wgs84 = $oGeoW->format_second;
# => (128376.14524...,502798.87076...)
DESCRIPTION
Constructor
new
my $obj = Location::GeoTool->new($option_hashref);
Creates Location::GeoTool object. With this constructor, you can set some options.
- enableWantarray
-
With this option is 1 (default 0), you can get coordinates array from "format_foo" or "datum_foo" type method in array context.
For example,
# When enableWantarray = 0 $obj_new = $obj->format_degree; # object ($lat,$long) = $obj->format_degree; # object,undef ($lat,$long) = $obj->format_degree->array;# latitude,longitude # When enableWantarray = 1 $obj_new = $obj->format_degree; # object ($lat,$long) = $obj->format_degree; # latitude,longitude ($lat,$long) = $obj->format_degree->array;# latitude,longitude
- changeMyself
-
With this option is 1 (default 0), "format_foo" or "datum_foo" type method won't make new object but change the original object itself.
For example,
# When changeMyself = 0 $obj_new = $obj->datum_tokyo; # $obj_new != $obj # $obj not change. # When changeMyself = 1 $obj_new = $obj->datum_tokyo; # $obj_new == $obj # $obj changes.
With new constructor, you can't set coordinates data. You must set them by using set_coord method.
create_coord
my $obj = Location::GeoTool->create_coord($lat,$long,$datum,$format);
Creates Location::GeoTool object. This method can not only create object but set coordinates, but cannot set options.
$lat : Latitude
$long : Longitude
$datum : Datum
$format : Format
Default datum and format of object are same with given to constructor. Give datum by string shown below:
WGS84 : 'wgs84'
TOKYO : 'tokyo'
Give format by string shown below:
MapionURL format (ddd/mm/ss.nnn) : 'mapion'
gpsOne format (ddd.mm.ss.nnn) : 'gpsone'
SpaceTag format (pddmmssnnn) : 'spacetag'
dddmmss.nnn·Á¼° : 'dmsn'
Degree (ddd.dddddd...) : 'degree'
Second (ssssss.sss...) : 'second'
Radian : 'radian'
Methods for setting/changing latitude/longitude
set_coord
$obj->set_coord($lat,$long,$datum,$format);
This method to be used when setting/changing object's cordinates data. Argument is same with create_coord.
Methods for setting/changing option
enableWantarray
changeMyself
$obj->enableWantarray(1);
$obj->changeMyself(1);
This method to be used when setting/changing object's option value. Option's meaning is same with new method's option.
Methods for getting latitude/longitude
array
lat
long
Return the latitude/longitude value of object.
($lat,$long) = $obj->array;
or
$lat = $obj->lat;
$long = $obj->long;
Methods for changing datum/format
format_foo
datum_foo
Create a new object which has new datum/format setting. (With changeMyself option on, never create new object but change original object)
$newobj = $obj->datum_wgs84;
$newobj = $obj->format_mapion;
($lat,$long) = $obj->datum_tokyo->format_radian->array;
etc.
All methods belong to this category are shown below:
Change to wgs84 datum : datum_wgs84
Change to tokyo datum : datum_tokyo
Change to MapionURL format : format_mapion
Change to gpsOne format : format_gpsone
Change to SpaceTag format : format_spacetag
Change to dddmmss.nnn : format_dmsn
Change to degree : format_degree
Change to second : format_second
Change to radian : format_radian
Methods for create Location::GeoTool::Direction object
Create a object of Location::GeoTool::Direction, which is handling direction/distance data. Parent object is automatically set to Start-point of Location::GeoTool::Direction object.
my $dirobj = $locobj->direction_point('40/36/14.307','141/01/33.022','tokyo','mapion');
my ($dir,$dist) = ($dirobj->direction,$dirobj->distance);
or
my $direction = $locobj->direction_point($another_locobj)->direction;
or
my ($endlat,$endlong) = $locobj->direction_vector($dir,$dist)->to_point->array;
etc.
direction_point
Create Location::GeoTool::Direction object by giving End-point.
You can specify End-point by two-ways shown below:
$locobj->direction_point($lat,$long,$datum,$format);
or
$locobj->direction_point($another_locobj);
#$another_locobj is another Location::GeoTool object
direction_vector
Create Location::GeoTool::Direction object by giving direction and distance.
$locobj->direction_point($direction,$distance);
Direction is given 0-360 degree, start from north, and east is positive. Unit of distance is [m].
Create Location::GeoTool::Direction object by giving End-point.
PLUGINS
If you want to use plugin of this module, you use this module as below:
use Location::GeoTool qw/Locapoint GridLocator/;
By above, you can use Location::GeoTool::Plugin::Locapoint and Location::GeoTool::Plugin::GridLocator plugin.
These two plugins are combined with this distribution.
DEPENDENCIES
Math::Trig
SEE ALSO
dir_dist2point, dir_dist2point function is based on javascript program could be seen in http://williams.best.vwh.net/gccalc.htm
datumchange and molodensly function is based on perl program could be seen in http://member.nifty.ne.jp/Nowral/02_DATUM/Molodensky.html
Thanks for these site.
Support this module in Kokogiko! web site : http://kokogiko.net/
AUTHOR
OHTSUKA Ko-hei, <nene@kokogiko.net>
COPYRIGHT AND LICENSE
Copyright (C) 2003-2007 by Kokogiko!,
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.1 or, at your option, any later version of Perl 5 you may have available.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 816:
Non-ASCII character seen before =encoding in 'dddmmss.nnn·Á¼°'. Assuming CP1252