"Fossies" - the Fresh Open Source Software Archive

Member "PDL-2.080/GENERATED/PDL/GIS/Proj.pm" (28 May 2022, 5255 Bytes) of package /linux/misc/PDL-2.080.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Proj.pm" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.079_vs_2.080.

    1 #
    2 # GENERATED WITH PDL::PP! Don't modify!
    3 #
    4 package PDL::GIS::Proj;
    5 
    6 our @EXPORT_OK = qw( get_proj_info  fwd_transform inv_transform  load_projection_descriptions proj_version   load_projection_information  );
    7 our %EXPORT_TAGS = (Func=>\@EXPORT_OK);
    8 
    9 use PDL::Core;
   10 use PDL::Exporter;
   11 use DynaLoader;
   12 
   13 
   14    
   15    our @ISA = ( 'PDL::Exporter','DynaLoader' );
   16    push @PDL::Core::PP, __PACKAGE__;
   17    bootstrap PDL::GIS::Proj ;
   18 
   19 
   20 
   21 
   22 
   23 
   24 #line 19 "Proj.pd"
   25 
   26 use strict;
   27 use warnings;
   28 
   29 =head1 NAME
   30 
   31 PDL::GIS::Proj - PDL interface to the PROJ projection library.
   32 
   33 =head1 DESCRIPTION
   34 
   35 For more information on the PROJ library, see: L<http://www.proj.org/>
   36 #line 37 "Proj.pm"
   37 
   38 
   39 
   40 
   41 
   42 
   43 =head1 FUNCTIONS
   44 
   45 =cut
   46 
   47 
   48 
   49 
   50 #line 64 "Proj.pd"
   51 
   52 =head2 get_proj_info($params_string)
   53 
   54 Returns a string with information about what parameters proj will
   55 actually use, this includes defaults, and +init=file stuff. It's 
   56 the same as running 'proj -v'. It uses the proj command line, so
   57 it might not work with all shells. I've tested it with bash.
   58 
   59 =cut
   60 
   61 sub get_proj_info
   62 {
   63     my $params = shift;
   64     my @a = split(/\n/, `echo | proj -v $params`);
   65     pop(@a);
   66     return join("\n", @a);
   67 } # End of get_proj_info()...
   68 #line 69 "Proj.pm"
   69 
   70 
   71 
   72 #line 948 "../../../blib/lib/PDL/PP.pm"
   73 
   74 
   75 
   76 =head2 fwd_transform
   77 
   78 =for sig
   79 
   80   Signature: (lonlat(n=2); [o] xy(n); char* params)
   81 
   82 =for ref
   83 
   84 PROJ forward transformation $params is a string of the projection
   85 transformation parameters.
   86 
   87 Returns a pdl with x, y values at positions 0, 1. The units are dependent
   88 on PROJ behavior. They will be PDL->null if an error has occurred.
   89 
   90 =for bad
   91 
   92 Ignores bad elements of $lat and $lon, and sets the corresponding elements
   93 of $x and $y to BAD
   94 
   95 
   96 =for bad
   97 
   98 fwd_transform processes bad values.
   99 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  100 
  101 
  102 =cut
  103 #line 104 "Proj.pm"
  104 
  105 
  106 
  107 #line 950 "../../../blib/lib/PDL/PP.pm"
  108 
  109 *fwd_transform = \&PDL::fwd_transform;
  110 #line 111 "Proj.pm"
  111 
  112 
  113 
  114 #line 948 "../../../blib/lib/PDL/PP.pm"
  115 
  116 
  117 
  118 =head2 inv_transform
  119 
  120 =for sig
  121 
  122   Signature: (xy(n=2); [o] lonlat(n); char* params)
  123 
  124 =for ref
  125 
  126 PROJ inverse transformation $params is a string of the projection
  127 transformation parameters.
  128 
  129 Returns a pdl with lon, lat values at positions 0, 1. The units are
  130 dependent on PROJ behavior. They will be PDL->null if an error has
  131 occurred.
  132 
  133 =for bad
  134 
  135 Ignores bad elements of $lat and $lon, and sets the corresponding elements
  136 of $x and $y to BAD
  137 
  138 
  139 =for bad
  140 
  141 inv_transform processes bad values.
  142 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  143 
  144 
  145 =cut
  146 #line 147 "Proj.pm"
  147 
  148 
  149 
  150 #line 950 "../../../blib/lib/PDL/PP.pm"
  151 
  152 *inv_transform = \&PDL::inv_transform;
  153 #line 154 "Proj.pm"
  154 
  155 
  156 
  157 #line 213 "Proj.pd"
  158 
  159 
  160 =head2 proj_version
  161 
  162 Returns a 3-element list with PROJ major, minor, patch version-numbers.
  163 
  164 =cut
  165 
  166 my %SKIP = map +($_=>1), qw(
  167   and or Special for Madagascar
  168   fixed Earth For CH1903
  169 );
  170 
  171 sub load_projection_information
  172 {
  173     my $descriptions = PDL::GIS::Proj::load_projection_descriptions();
  174     my $info = {};
  175     foreach my $projection ( sort keys %$descriptions )
  176     {
  177         my $description = $descriptions->{$projection};
  178         my $hash = {CODE => $projection};
  179         my @lines = split( /\n/, $description );
  180         chomp @lines;
  181         # Full name of this projection:
  182         ($hash->{NAME}, my $temp) = splice @lines, 0, 2;
  183         if ($temp) {
  184           # The second line is usually a list of projection types this one is:
  185           $temp =~ s/no inv\.*,*//;
  186           $temp =~ s/or//;
  187           my @temp_types = split(/[,&\s]/, $temp );
  188           my @types = grep( /.+/, @temp_types );
  189           $hash->{CATEGORIES} = \@types;
  190         }
  191         # If there's more than 2 lines, then it usually is a listing of parameters:
  192         # General parameters for all projections:
  193         $hash->{PARAMS}->{GENERAL} = 
  194             [ qw( x_0 y_0 lon_0 units init no_defs geoc over ) ];
  195         # Earth Figure Parameters:
  196         $hash->{PARAMS}->{EARTH} = 
  197             [ qw( ellps b f rf e es R R_A R_V R_a R_g R_h R_lat_g ) ];
  198         # Projection Specific Parameters:
  199         $hash->{PARAMS}{PROJ} = [
  200           grep !$SKIP{$_}, map {s/=//; s/[,\[\]]//sg; $_}
  201             grep length, map split(/\s+/), @lines
  202         ];
  203         # Can this projection do inverse?
  204         $hash->{INVERSE} = ( $description =~ /no inv/ ) ? 0 : 1;
  205         $info->{$projection} = $hash;
  206     }
  207     # A couple of overrides:
  208     #
  209     $info->{ob_tran}{PARAMS}{PROJ} =
  210         [ 'o_proj', 'o_lat_p', 'o_lon_p', 'o_alpha', 'o_lon_c', 
  211           'o_lat_c', 'o_lon_1', 'o_lat_1', 'o_lon_2', 'o_lat_2' ];
  212     $info->{nzmg}{CATEGORIES} = [ 'fixed Earth' ];
  213     return $info;
  214 } # End of load_projection_information()...
  215 #line 216 "Proj.pm"
  216 
  217 
  218 
  219 
  220 
  221 #line 32 "Proj.pd"
  222 
  223 =head1 AUTHOR
  224 
  225 Judd Taylor, Orbital Systems, Ltd.
  226 judd dot t at orbitalsystems dot com
  227 
  228 =head1 COPYRIGHT NOTICE
  229 
  230 Copyright 2003 Judd Taylor, USF Institute for Marine Remote Sensing (judd@marine.usf.edu).
  231 
  232 GPL Now!
  233 
  234 This program is distributed in the hope that it will be useful,
  235 but WITHOUT ANY WARRANTY; without even the implied warranty of
  236 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  237 
  238 =cut
  239 #line 240 "Proj.pm"
  240 
  241 
  242 
  243 
  244 # Exit with OK status
  245 
  246 1;