Geo::Proj(3pm) | User Contributed Perl Documentation | Geo::Proj(3pm) |
Geo::Proj - Handling projections
use Geo::Proj; my $wgs84 = Geo::Proj->new # predefined if import() ( nick => 'wgs84' , proj4 => '+proj=latlong +datum=WGS84 +ellps=WGS84' ); my $clrk = Geo::Proj->new ( nick => 'clark66' , proj4 => [proj => "merc", ellps => "clrk66", lon_0 => -96] ); my $point_wgs84= Geo::Point->latlong(56.12, 4.40, 'wgs84'); my $point_wgs84= Geo::Point->latlong(56.12, 4.40, $wgs84); my $point_clrk = $point_wgs84->in($clrk); my $point_clrk = Geo::Proj->to($wgs84, $clrk, $point_wgs84); my $point_clrk = Geo::Proj->to($wgs84, 'clark66', $point_wgs84);
A point on Earth's surface can be represented in many different coordinate systems. The Geo::Proj4 module wraps the popular Open Source "libproj" library to convert between those coordinate systems; a very complex job.
Within a program, however, you like some extra abstraction from that library: to be able to simply label a point to its system, and then forget about all transformations which may be necessary. The label (or "nick") hides all complicated parameters for the actual projection .
WARNING 1: this class will collect all nicks, which means that calling new() with the same label twice will have the second ignored.
WARNING 2: the wgs84 nickname is predefined, but only if this module is 'used' with import. So if you decide to use 'require' to dynamically load this module, then don't forget to call 'import()' yourself, or define the wgs84 projection yourself.
-Option--Default name <from proj4> nick <required> proj4 <required> srid undef
example:
my $wgs84 = Geo::Proj->new(nick => 'wgs84', ...); my $wgs84_proj4 = Geo::Proj->proj4('wgs84'); my $wgs84_proj4 = Geo::Proj->proj4($wgs84); my $wgs84_proj4 = $wgs84->proj4;
example:
my $wgs84 = Geo::Proj->projection('wgs84'); my $again = Geo::Proj->projection($wgs84);
Be warned that this to() method expects POINTs which are not Geo::Point objects, but which themselves are an ARRAY containing X,Y and optionally a Z coordinate.
example:
my $p2 = $wgs84->to('utm31-wgs84', $p1); my $p2 = $wgs84->to($utm, $p1); my $p2 = Geo::Proj->to('wgs84', 'utm31-wgs84', $p1);
example:
my $proj = Geo::Proj->UTMprojection('WGS84', 31) or die; print $proj->nick; # for instance utm31-wgs84
example:
my $point = Geo::Point->longlat(2.234, 52.12); my $proj = Geo::Proj->bestUTMprojection($point); print $proj->nick; # for instance utm31-wgs84
This code is stolen from Geo::Coordinates::UTM, because that module immediately starts to do computations with this knowledge, which is not wanted here. Probably a lot of zones are missing.
This module is part of Geo-Point distribution version 0.98, built on February 01, 2019. Website: http://perl.overmeer.net/CPAN/
Copyrights 2005-2019 by [Mark Overmeer]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/
2019-02-21 | perl v5.28.1 |