Geo-Proj4-1.09/0000755000175000001440000000000013231664750013676 5ustar00markovusers00000000000000Geo-Proj4-1.09/examples/0000755000175000001440000000000013231664750015514 5ustar00markovusers00000000000000Geo-Proj4-1.09/examples/use_epsg.pl0000644000175000001440000000213313231664747017670 0ustar00markovusers00000000000000#!/usr/bin/perl -w # Example contributed by Michael R. Davis, see after __END__ use strict; use warnings; use Geo::Proj4 (); my $epsg = 26985; my $proj = Geo::Proj4->new(init => "epsg:$epsg") or die "cannot use EPSG 26985: ",Geo::Proj4->error, "\n"; my ($x, $y) = (401717.80, 130013.88); my ($lat, $lon) = $proj->inverse($x, $y); print " x: $x\n y: $y\nlat: $lat\nlon: $lon\n"; __END__ Proj4 EPSG Example Convert SPCS83 Maryland zone (meters) to Latitude and Longitude Projection Input: Code - CRS: 26985 CRS Name: NAD83 / Maryland CRS Type: projected Coord Sys code: 4499 CS Type: Cartesian Dimension: 2 Remarks: Used in projected and engineering coordinate reference systems. CRS Name: NAD83 Datum Name: North American Datum 1983 Datum Origin: Origin at geocentre. Ellipsoid Name: GRS 1980 Ellipsoid Unit: metre Coord Operation Name: SPCS83 Maryland zone (meters) Coord Op Method Name: Lambert Conic Conformal (2SP) Output Unprojected Latitude and Longitude, probably with GRS80 ellipsoids. Copyright Copyright 2007 Michael R. Davis License MIT, BSD, Perl, or GPL Geo-Proj4-1.09/examples/test_list.pl0000644000175000001440000000222013231664747020065 0ustar00markovusers00000000000000#!/usr/bin/env perl # when run, it will show all definitions. use warnings; use strict; use lib qw[blib/lib blib/arch ../blib/lib ../blib/arch]; use Geo::Proj4; print "Ellisoids:\n"; my @ells = Geo::Proj4->listEllipsoids; foreach my $ell (@ells) { my $def = Geo::Proj4->ellipsoidInfo($ell); print " $ell: $def->{name}\n" , " ellipses: $def->{ell}" , ", major: $def->{major}\n"; } print "\nUnits:\n"; my @units = Geo::Proj4->listUnits; foreach my $unit (@units) { my $def = Geo::Proj4->unitInfo($unit); printf " %6s: %12.6f meter; %s\n", $unit, $def->{to_meter}, $def->{name}; } print "\nDatums:\n"; my @datums = Geo::Proj4->listDatums; foreach my $datum (@datums) { my $def = Geo::Proj4->datumInfo($datum); print " $datum: ", ($def->{comments}||''), "\n" , " $def->{definition}\n"; } print "\nProjections:\n"; my @types = Geo::Proj4->listTypes; foreach my $type (@types) { my $def = Geo::Proj4->typeInfo($type); my $descr = $def->{description} || ''; $descr =~ s/\s*\z//; $descr .= "\n(has inverse)" if $def->{has_inverse}; $descr =~ s/\n\s*/\n /g; print " $type: $descr\n"; } Geo-Proj4-1.09/examples/sample.pl0000644000175000001440000000060113231664747017335 0ustar00markovusers00000000000000#!/usr/bin/perl use strict; use warnings; use Geo::Proj4; my $proj = Geo::Proj4->new( proj => "utm", zone => 10 ); my ($x, $y) = $proj->forward(38.40342, -122.81856); print "conversion to UTM: y is $y\n"; print "conversion to UTM: x is $x\n"; my ($lat, $long) = $proj->inverse($x, $y); print "inverse conversion: lat is $lat \n" ; print "inverse conversion: long is $long \n" ; Geo-Proj4-1.09/t/0000755000175000001440000000000013231664750014141 5ustar00markovusers00000000000000Geo-Proj4-1.09/t/10utm.t0000644000175000001440000000641213231664747015305 0ustar00markovusers00000000000000#!/usr/bin/perl use strict; use warnings; use Test::More tests => 43; use lib qw[blib/lib blib/arch]; use_ok('Geo::Proj4'); my $version = Geo::Proj4->libVersion; ok(defined $version, "library version $version"); ok(1,'Start testing Lat/Long to/from UTM'); my $proj = Geo::Proj4->new(proj => "utm", zone => 10, datum => 'WGS84'); unless(defined $proj) { my $err = Geo::Proj4->error; warn +($err+0).": ".$err; exit 1; } ok(defined $proj, "object creation"); isa_ok($proj, "Geo::Proj4"); is($proj->normalized, "+proj=utm +zone=10 +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0" ); ok(not $proj->isLatlong); ok(not $proj->isGeodesic); ok(not $proj->isGeocentric); # convert from lat/long to UTM my @rv = ( { name => "imaginary" , lat => 38.40249 , long => -122.82888 , northing => 4250487 , easting => 514941 } , { name => "O'Reilly" , lat => 38.40342 , long => -122.81856 , northing => 4250592 , easting => 515842 } , { name => "Unicorn Precinct" , lat => 37.73960, , long => -122.41980, , northing => 4177082, , easting => 551119, } ); foreach my $c (@rv) { my ($x, $y) = $proj->forward($c->{lat}, $c->{long}); cmp_ok(int $x, '==', $c->{easting}, "$c->{name} forward to UTM x"); cmp_ok(int $y, '==', $c->{northing}, "$c->{name} forward to UTM y"); my ($lat, $long) = $proj->inverse($x, $y); cmp_ok(int $lat, '==', int $c->{lat}, "$c->{name} inverse lat"); cmp_ok(int $long, '==', int $c->{long}, "$c->{name} inverse long"); } my ($long, $lat) = (-122.82888, 38.40249); my ($x, $y) = $proj->forward($lat, $long); cmp_ok(int $x, '==', 514941, "forward to UTM x"); cmp_ok(int $y, '==', 4250487, "forward to UTM y"); my ($lat2, $long2) = $proj->inverse($x, $y); cmp_ok(int $lat, '==', int $lat2, "inverse lat"); cmp_ok(int $long, '==', int $long2, "inverse long"); # # repeated forward-inverse # ($long, $lat) = (-122.82888, 38.40249); for (1..10) { ($x, $y) = $proj->forward($lat, $long); ($lat, $long) = $proj->inverse($x, $y); } cmp_ok(int $x, '==', 514941, "Run 10 convs to UTM x"); cmp_ok(int $y, '==', 4250487, "Run 10 convs to UTM y"); cmp_ok(int $lat, '==', int $lat2, "Run 10 inverse convs lat"); cmp_ok(int $long, '==', int $long2, "Run 10 inverse convs long"); # # The same, but now using transform # my $from = Geo::Proj4->new(proj=>'latlong', ellps=>'WGS84',datum=>'WGS84'); unless(defined $from) { my $err = Geo::Proj4->error; warn +($err+0).": ".$err; exit 1; } ok(defined $from, "object 'from' created explicitly"); ok($from->isLatlong); foreach my $c (@rv) { my($point) = $from->transform($proj, [$c->{long}, $c->{lat}]); unless(defined $point) { my $err = Geo::Proj4->error; warn +($err+0).": ".$err; next; } cmp_ok(int $point->[0],'==', $c->{easting}, "$c->{name} forward to UTM x"); cmp_ok(int $point->[1],'==', $c->{northing}, "$c->{name} forward to UTM y"); my($back) = $proj->transform($from, $point); unless(defined $back) { my $err = Geo::Proj4->error; warn +($err+0).": ".$err; next; } cmp_ok(int $back->[0], '==', int $c->{long}, "$c->{name} inverse long"); cmp_ok(int $back->[1], '==', int $c->{lat}, "$c->{name} inverse lat"); } Geo-Proj4-1.09/t/20clark80.t0000644000175000001440000000443613231664747015751 0ustar00markovusers00000000000000#!/usr/bin/perl # Convert wgs84 to clark80 as example of a lat-long to lat-long conversion. use strict; use warnings; use Test::More tests => 21; use lib qw[blib/lib blib/arch]; use_ok('Geo::Proj4'); my $version = Geo::Proj4->libVersion; ok(defined $version, "library version $version"); ok(1,'Start testing Lat/Long to/from UTM'); my $from = Geo::Proj4->new(proj => 'latlong', ellps => 'WGS84'); defined $from or die Geo::Proj4->error; isa_ok($from, "Geo::Proj4"); is($from->normalized, '+proj=latlong +ellps=WGS84'); ok($from->isLatlong); ok($from->isGeodesic); ok(not $from->isGeocentric); my $proj = Geo::Proj4->new("+proj=latlong +ellps=clrk80"); isa_ok($proj, "Geo::Proj4"); defined $proj or die Geo::Proj4->error; is($proj->normalized, '+proj=latlong +ellps=clrk80'); ok($proj->isLatlong); ok($proj->isGeodesic); ok(not $proj->isGeocentric); #$from->dump; #$proj->dump; # convert from wgs84 to clark80 my @rv = ( { name => "imaginary" , wgs_lat => 38.40249 , wgs_long => -122.82888 , cl_lat => 38.40249 , cl_long => -122.82888 } ); sub about($$$) { my ($float1, $float2, $text) = @_; my $dist = abs($float1/$float2 -1); if($dist < 0.0001) { ok(1, $text) } else { my $percent = sprintf "%.6f", $dist; ok(0, "$text fail: $float1/$float2 $percent%"); } } foreach my $c (@rv) { my $point = [ $c->{wgs_long}, $c->{wgs_lat} ]; my $pr = $from->transform($proj, $point); my ($cl_long, $cl_lat) = @$pr; about($cl_lat, $c->{cl_lat}, "$c->{name} forward clark80 lat"); about($cl_long, $c->{cl_long}, "$c->{name} forward clark80 long"); my $w_pr = $proj->transform($from, [$cl_long, $cl_lat] ); my ($w_long, $w_lat) = @$w_pr; about($w_lat, $c->{wgs_lat}, "$c->{name} inverse lat"); about($w_long, $c->{wgs_long}, "$c->{name} inverse long"); } # # repeated forward-inverse # my $one = $rv[0]; my ($w_lat, $w_long) = @{$one}{ qw/wgs_lat wgs_long/ }; my ($cl_lat, $cl_long); for (1..10) { ($cl_long, $cl_lat) = $proj->forward($w_lat, $w_long); ($w_lat, $w_long) = $proj->inverse($cl_long, $cl_lat); } about($w_lat, $one->{wgs_lat}, "Run 10 wgs_lat"); about($w_long, $one->{wgs_long}, "Run 10 wgs_long"); about($cl_lat, $one->{cl_lat}, "Run 10 cl_lat"); about($cl_long, $one->{cl_long}, "Run 10 cl_long"); Geo-Proj4-1.09/lib/0000755000175000001440000000000013231664750014444 5ustar00markovusers00000000000000Geo-Proj4-1.09/lib/Geo/0000755000175000001440000000000013231664750015156 5ustar00markovusers00000000000000Geo-Proj4-1.09/lib/Geo/Proj4.pod0000644000175000001440000002637213231664747016700 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME Geo::Proj4 - PROJ.4 cartographic projections library =head1 INHERITANCE Geo::Proj4 is a DynaLoader =head1 SYNOPSIS use Geo::Proj4; my $proj = Geo::Proj4->new(proj => "merc", ellps => "clrk66", lon_0 => -96) or die "parameter error: ".Geo::Proj4->error. "\n"; my $proj = Geo::Proj4->new("+proj=merc +ellps=clrk66 +lon_0=-96") or die "parameter error: ".Geo::Proj4->error. "\n"; my $proj = Geo::Proj4->new(init => "epsg:28992"); my ($x, $y) = $proj->forward($lat, $lon); if($proj->hasInverse) { my ($lat, $lon) = $proj->inverse($x, $y); ... } my $proj = Geo::Proj4->new(init => "epsg:26985") or die; my ($lat, $lon) = $proj->inverse(401717.80, 130013.88); my $point = [ 123.12, -5.4 ]; my $projected_point = $from->transform($to, $point); my $projected_multi = $from->transform($to, \@points); =head1 DESCRIPTION The Open Source PROJ.4 library converts between geographic coordinate systems. It is able to convert between geodetic latitude and longitude (LL, most commonly the WGS84 projection), into an enormous variety of other cartographic projections (XY, usually UTM). WARNING: It is not always clear what the source projection is when L or L are used, i.e. in what projection system the source data is expected to be in. Therefore, you can better be specific on both source and destination projection and use L. =head1 METHODS =head2 Instantiation =over 4 =item Geo::Proj4-EB($string|%options) The object defines the target projection, but that's easier said than done: projections have different parameter needs. The parameters which can (or need to) be used are listed with C. The manual page of C explains how the configuration works. Two ways are provided to define the projection. Either, use a list of %options, which are pairs of parameters, or pass one string which contains all parameters at once. You must supply a C parameter. In case of an OPTION list: WARNING: Specify boolean parameters (e.g. the south parameter to the UTM projection) with a matching value of undef. example: my $proj = Geo::Proj4->new(proj => "merc", ellps => "clrk66", lon_0 => -96 ) or die Geo::Proj4->error; my $proj = Geo::Proj4->new("+proj=merc +ellps=clrk66 +lon_0=096") or die Geo::Proj4->error; my $proj = Geo::Proj4->new(init => "epsg:$epsg"); =back =head2 Accessors =over 4 =item $obj-EB() Tries to return a datum name for this projection. =item $obj-EB() Write the definition in extended form to stdout. This output cannot be caught, because it is done on stdio level, below the reach of PerlIO. =item Geo::Proj4-EB() Returns a dualvar (see Scalar::Util) containing the error number and error string of the last reported error. example: my $proj = Geo::Proj4->new(...); unless(defined $proj) { my $error = Geo::Proj4->error; warn "error-code: ".$error+0; warn "error-string: $error\n"; } =item $obj-EB() Returns whether the reverse function for the projection exists. Some projections are one-way. =item $obj-EB() Returns true when the source projection is using a geocentric coordinate system; i.e. uses x-y coordinates. =item $obj-EB() Returns true when the source projection is using a geodetic coordinate system; i.e. uses lat long coordinates. Same as L =item $obj-EB() Returns true when the source projection is using a geodetic coordinate system; i.e. uses lat long coordinates. Same as L. =item $obj-EB() Returns a string which is produced by the library based on the data extracted from the initiation parameters. This string may be more explicit than the passed values, and could be used for debugging. =item $obj-EB() Returns the projection type. =back =head2 Converters =over 4 =item $obj-EB($latitude, $longitude) Perform a forward projection from $latitude and $longitude (LL) to the cartographic projection (XY) represented by the Geo::Proj4 instance. WARNING: for historic reasons, latitude and longitude are assumed to be in (floating point) degrees, although the library expects rads. See L. A latitude south of the Equator and longitude west of the Prime Meridian given with negative values. Returned are two values, usually X and Y in meters, or whatever units are relevant to the given projection. When the destination projection also than the order of parameters will be returned as LONG,LAT (not lat,long!) On error, C will return undef for both values. example: my ($x, $y) = $proj->forward($lat, $lon); my ($long2, $lat2) = $proj->forward($lat, $lon); =item $obj-EB($latitude, $longitude) Perform a forward projection from $latitude and $longitude (LL) to the cartographic projection (XY) represented by the Geo::Proj4 instance. This function reflects to library function C, expecting radians, not degrees. =item $obj-EB(($x,$y) | ($lat,$long)) Perform an inverse projection from the (cartographic) projection represented by this Geo::Proj4 object, back into latitude and longitude values. WARNING: for historic reasons, latitude and longitude are assumed to be in (floating point) degrees, although the library expects rads. See L. On error, C will return undef for both values. example: if($proj->hasInverse) { my ($lat, $lon) = $proj->inverse($x, $y); ... } =item $obj-EB(($x,$y) | ($lat|$long)) Perform an inverse projection from the (cartographic) projection represented by this Geo::Proj4 object, back into latitude and longitude values. Latitude and longitude are assumed to be in radians. See L. =item $obj-EB($to, $point|ARRAY-of-$points) Translate the $points into the projecten of $to. Each point is specified as two or three values in an ARRAY. In case of latlong source or destination projections, coordinates are translated into radians and/or back. Both input and output values are always in X-Y/LongLat order. See L example: my $from = Geo::Proj4->new("+proj=latlong +datum=NAD83"); my $to = Geo::Proj4->new("+proj=utm +zone=10 +datum=WGS84"); my $point = [ 1.12, 3.25 ]; # See Geo::Point my $pr_point = $from->transform($to, $point); my $pr = $from->transform($to, [ $point1, $point2 ]); my $pr_point1 = $pr->[0]; my $pr_point2 = $pr->[1]; =item $obj-EB($to, $point|ARRAY-of-$points) Translate the $points into the projecten of $to. Each point is specified as two or three values in an ARRAY. In case of latlong source or destination projections, coordinates are expected to be in radians. Both input and output values are always in X-Y/LongLat order. See L =back =head2 Library introspection =over 4 =item Geo::Proj4-EB($label) Returns a hash with information about the specified datum. With L, all defined LABELS can be found. =item Geo::Proj4-EB($label) Returns a hash with information about the specified ellipsis. With L, all defined LABELS can be found. =item $obj-EB() =item Geo::Proj4-EB() Returns the version of the proj4 library =item Geo::Proj4-EB() Returns a list with all defined datum labels. example: foreach my $id (Geo::Proj4->listDatums) { my $def = Geo::Proj4->datum($id); print "$id = $def->{ellips_id}\n"; } =item Geo::Proj4-EB() Returns a list with all defined ellips labels. example: foreach my $id (Geo::Proj4->listEllipsoids) { my $def = Geo::Proj4->ellipsoid($id); print "$id = $def->{name}\n"; } =item Geo::Proj4-EB() Returns a list with all defined projection types. example: foreach my $id (Geo::Proj4->listTypes) { my $def = Geo::Proj4->type($id); print "$id = $def->{description}\n"; } =item Geo::Proj4-EB() Returns a list with all defined unit labels. example: foreach my $id (Geo::Proj4->listUnits) { my $def = Geo::Proj4->unit($id); print "$id = $def->{name}\n"; } =item Geo::Proj4-EB($label) Returns a hash with information about the specified projection type. With L, all defined LABELS can be found. =item Geo::Proj4-EB($label) Returns a hash with information about the specified unit. With L, all defined LABELS can be found. =back =head1 DETAILS =head2 Install Geo::Proj4 uses XS to wrap the PROJ.4 cartographic projections library. You will need to have the PROJ.4 library installed in order to build and use this module. You can get source code and binaries for the PROJ.4 library from its home page at L. =head2 Projections Covering all the possible projections and their arguments in PROJ.4 is well beyond the scope of this document. However, the C utility that ships with PROJ.4 will list the projections it knows about by running B, the ellipsoid models it knows with the B<-le> parameter, the units it knows about with B<-lu>, and the geodetic datums it knows with B<-ld>. Read L for more details. Alternately, you can read the PROJ.4 documentation, which can be found on the project's homepage. There are links to PDFs, text documentation, a FAQ, and more. =head2 Bugs One common source of errors is that latitude and longitude are swapped: some projection systems use lat-long, other use x-y which is a swapped order. Especially the L and L cause this problem, always flipping the coordinate order. The L method is much easier: input and output in x-y/long-lat order. Also be warned that the values must have the right sign. Make sure you give negative values for south latitude and west longitude. For calculating projections, this is more important than on maps. =head1 DIAGNOSTICS =over 4 =item Error: transform() expects array of points =item Error: transformRad() expects array of points =back =head1 REFERENCES See the Geo::Point website at L for an html version of this and related modules; Effusive thanks to Frank Warmerdam (maintainer of PROJ.4) and Gerald Evenden (main contributor of PROJ.4). Their PROJ.4 library home page: L proj(1), cs2cs(1), pj_init(3). =head1 COPYRIGHTS Developed and maintained by Mark Overmeer Emarkov@cpan.orgE. Copyright (c) 2004-2018 by the authors. All rights reserved. Originally Written by Schuyler Erle Eschuyler@nocat.netE and Rich Gibson Erich@nocat.netE. Their site: Mapping Hacks home page: L =head1 LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Geo-Proj4-1.09/lib/Geo/Proj4.pm0000644000175000001440000000767213231664747016534 0ustar00markovusers00000000000000# Copyrights 2018 by [Mark Overmeer]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.02. # This code is part of distribution Geo-Proj4. Meta-POD processed with # OODoc into POD and HTML manual-pages. See README.md # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. package Geo::Proj4; use vars '$VERSION'; $VERSION = '1.09'; use strict; use warnings; #our $VERSION = '0.96'; use base 'DynaLoader'; use Scalar::Util qw/dualvar/; use Carp qw/croak/; # The library definitions bootstrap Geo::Proj4; # $VERSION; my $last_error; sub new($@) { my $class = shift; my $def; if(@_==1) { $def = shift; } else { my @args; while(@_) { my ($key, $val) = (shift, shift); push @args, "+$key".(defined $val ? "=$val" : ''); } $def = join ' ', @args; } my ($self, $error, $errtxt) = new_proj4($def); defined $self or $last_error = dualvar($error, $errtxt); $self; } #-------------- sub error() { $last_error } sub normalized() { my $norm = normalized_proj4(shift); $norm =~ s/^\s+//; $norm; } sub datum() { my $norm = shift->normalized; $norm =~ m/\+datum\=(w+)/ ? $1 : undef; } sub projection() { my $norm = shift->normalized; $norm =~ m/\+proj\=(\w+)/ ? $1 : undef; } sub dump() { dump_proj4(shift) } sub isLatlong() { is_latlong_proj4(shift) } sub isGeodesic() { is_latlong_proj4(shift) } sub isGeocentric() { is_geocentric_proj4(shift) } sub hasInverse() { has_inverse_proj4(shift) } #-------------- sub forward($$) { my ($self, $lat, $long) = @_; forward_degrees_proj4($self, $lat, $long); } sub forwardRad($$) { my ($self, $lat, $long) = @_; forward_proj4($self, $lat, $long); } sub inverse($$) { inverse_degrees_proj4(@_) } sub inverseRad($$) { inverse_proj4(@_) } sub transform($$) { my ($self, $to, $points) = @_; ref $points eq 'ARRAY' or croak "ERROR: transform() expects array of points"; my ($err, $errtxt, $pr); if(ref($points->[0]) eq 'ARRAY') { ($err, $errtxt, $pr) = transform_proj4($self, $to, $points, 1); } else { ($err, $errtxt, $pr) = transform_proj4($self, $to, [$points], 1); $pr = $pr->[0] if $pr; } $last_error = dualvar $err, $errtxt; $err ? () : $pr; } sub transformRad($$) { my ($self, $to, $points) = @_; ref $points eq 'ARRAY' or croak "ERROR: transformRad() expects array of points"; my ($err, $errtxt, $pr); if(ref($points->[0]) eq 'ARRAY') { ($err, $errtxt, $pr) = transform_proj4($self, $to, $points, 0); } else { ($err, $errtxt, $pr) = transform_proj4($self, $to, [$points], 0); $pr = $pr->[0] if $pr; } $last_error = dualvar $err, $errtxt; $err ? () : $pr; } sub AUTOLOAD(@) { our $AUTOLOAD; die "$AUTOLOAD not implemented"; } #-------------- sub libVersion() { my $version = libproj_version_proj4(); $version =~ s/./$&./g; $version; } sub listTypes() { &def_types_proj4 } sub typeInfo($) { my $label = $_[1]; my %def = (id => $label); my($descr) = type_proj4($label); $def{has_inverse} = not ($descr =~ s/(?:\,?\s+no\s+inv\.?)//); $def{description} = $descr; \%def; } sub listEllipsoids() { &def_ellps_proj4 } sub ellipsoidInfo($) { my $label = $_[1]; my %def = (id => $label); @def{ qw/major ell name/ } = ellps_proj4($label); \%def; } sub listUnits() { &def_units_proj4 } sub unitInfo($) { my $label = $_[1]; my %def = (id => $label); @def{ qw/to_meter name/ } = unit_proj4($label); $def{to_meter} =~ s!^1\.?/(.*)!1/$1!e; # 1/2 -> 0.5 \%def; } sub listDatums() { &def_datums_proj4 } sub datumInfo($) { my $label = $_[1]; my %def = (id => $label); @def{ qw/ellipse_id definition comments/ } = datum_proj4($label); \%def; } #-------------- # more text in PODTAIL.txt 1; Geo-Proj4-1.09/MANIFEST0000644000175000001440000000045513231664750015033 0ustar00markovusers00000000000000ChangeLog MANIFEST META.yml Makefile.PL Proj4.xs README examples/sample.pl examples/test_list.pl examples/use_epsg.pl lib/Geo/Proj4.pm lib/Geo/Proj4.pod src/4.8.0/projects.h t/10utm.t t/20clark80.t typemap xt/99pod.t META.json Module JSON meta-data (added by MakeMaker) Geo-Proj4-1.09/typemap0000644000175000001440000000060413231664747015306 0ustar00markovusers00000000000000TYPEMAP projPJ O_OBJECT OUTPUT O_OBJECT sv_setref_pv( $arg, "Geo::Proj4", (void*)$var ); INPUT O_OBJECT if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) $var = ($type)SvIV((SV*)SvRV( $arg )); else { /* original version had a line break here that broke the code. */ warn( \"${Package}::$func_name() - $var is not a blessed reference\" ); XSRETURN_UNDEF; } Geo-Proj4-1.09/src/0000755000175000001440000000000013231664750014465 5ustar00markovusers00000000000000Geo-Proj4-1.09/src/4.8.0/0000755000175000001440000000000013231664750015134 5ustar00markovusers00000000000000Geo-Proj4-1.09/src/4.8.0/projects.h0000644000175000001440000003532113231664747017150 0ustar00markovusers00000000000000/****************************************************************************** * $Id: projects.h 2121 2011-11-22 22:51:47Z warmerdam $ * * Project: PROJ.4 * Purpose: Primary (private) include file for PROJ.4 library. * Author: Gerald Evenden * ****************************************************************************** * Copyright (c) 2000, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. *****************************************************************************/ /* General projections header file */ #ifndef PROJECTS_H #define PROJECTS_H #ifdef _MSC_VER # ifndef _CRT_SECURE_NO_DEPRECATE # define _CRT_SECURE_NO_DEPRECATE # endif # ifndef _CRT_NONSTDC_NO_DEPRECATE # define _CRT_NONSTDC_NO_DEPRECATE # endif #endif /* standard inclusions */ #include #include #include #include #ifdef __cplusplus #define C_NAMESPACE extern "C" #define C_NAMESPACE_VAR extern "C" extern "C" { #else #define C_NAMESPACE extern #define C_NAMESPACE_VAR #endif #ifndef NULL # define NULL 0 #endif #ifndef FALSE # define FALSE 0 #endif #ifndef TRUE # define TRUE 1 #endif #ifndef MAX # define MIN(a,b) ((ab) ? a : b) #endif #ifndef ABS # define ABS(x) ((x<0) ? (-1*(x)) : x) #endif /* maximum path/filename */ #ifndef MAX_PATH_FILENAME #define MAX_PATH_FILENAME 1024 #endif /* prototype hypot for systems where absent */ #ifndef _WIN32 extern double hypot(double, double); #endif #ifdef _WIN32_WCE # include # include # define rewind wceex_rewind # define getenv wceex_getenv # define strdup _strdup # define hypot _hypot #endif /* some useful constants */ #define HALFPI 1.5707963267948966 #define FORTPI 0.78539816339744833 #define PI 3.14159265358979323846 #define TWOPI 6.2831853071795864769 /* environment parameter name */ #ifndef PROJ_LIB #define PROJ_LIB "PROJ_LIB" #endif /* maximum tag id length for +init and default files */ #ifndef ID_TAG_MAX #define ID_TAG_MAX 50 #endif /* Use WIN32 as a standard windows 32 bit declaration */ #if defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) # define WIN32 #endif #if defined(_WINDOWS) && !defined(WIN32) && !defined(_WIN32_WCE) # define WIN32 #endif /* directory delimiter for DOS support */ #ifdef WIN32 #define DIR_CHAR '\\' #else #define DIR_CHAR '/' #endif /* proj thread context */ typedef struct { int last_errno; int debug_level; void (*logger)(void *, int, const char *); void *app_data; } projCtx_t; /* datum_type values */ #define PJD_UNKNOWN 0 #define PJD_3PARAM 1 #define PJD_7PARAM 2 #define PJD_GRIDSHIFT 3 #define PJD_WGS84 4 /* WGS84 (or anything considered equivelent) */ /* library errors */ #define PJD_ERR_GEOCENTRIC -45 #define PJD_ERR_AXIS -47 #define PJD_ERR_GRID_AREA -48 #define USE_PROJUV typedef struct { double u, v; } projUV; typedef struct { double r, i; } COMPLEX; #ifndef PJ_LIB__ #define XY projUV #define LP projUV #else typedef struct { double x, y; } XY; typedef struct { double lam, phi; } LP; #endif typedef union { double f; int i; char *s; } PVALUE; struct PJconsts; struct PJ_LIST { char *id; /* projection keyword */ struct PJconsts *(*proj)(struct PJconsts*);/* projection entry point */ char * const *descr; /* description text */ }; struct PJ_ELLPS { char *id; /* ellipse keyword name */ char *major; /* a= value */ char *ell; /* elliptical parameter */ char *name; /* comments */ }; struct PJ_UNITS { char *id; /* units keyword */ char *to_meter; /* multiply by value to get meters */ char *name; /* comments */ }; struct PJ_DATUMS { char *id; /* datum keyword */ char *defn; /* ie. "to_wgs84=..." */ char *ellipse_id; /* ie from ellipse table */ char *comments; /* EPSG code, etc */ }; struct PJ_PRIME_MERIDIANS { char *id; /* prime meridian keyword */ char *defn; /* offset from greenwich in DMS format. */ }; struct DERIVS { double x_l, x_p; /* derivatives of x for lambda-phi */ double y_l, y_p; /* derivatives of y for lambda-phi */ }; struct FACTORS { struct DERIVS der; double h, k; /* meridinal, parallel scales */ double omega, thetap; /* angular distortion, theta prime */ double conv; /* convergence */ double s; /* areal scale factor */ double a, b; /* max-min scale error */ int code; /* info as to analytics, see following */ }; #define IS_ANAL_XL_YL 01 /* derivatives of lon analytic */ #define IS_ANAL_XP_YP 02 /* derivatives of lat analytic */ #define IS_ANAL_HK 04 /* h and k analytic */ #define IS_ANAL_CONV 010 /* convergence analytic */ /* parameter list struct */ typedef struct ARG_list { struct ARG_list *next; char used; char param[1]; } paralist; /* base projection data structure */ typedef struct PJconsts { projCtx_t *ctx; XY (*fwd)(LP, struct PJconsts *); LP (*inv)(XY, struct PJconsts *); void (*spc)(LP, struct PJconsts *, struct FACTORS *); void (*pfree)(struct PJconsts *); const char *descr; paralist *params; /* parameter list */ int over; /* over-range flag */ int geoc; /* geocentric latitude flag */ int is_latlong; /* proj=latlong ... not really a projection at all */ int is_geocent; /* proj=geocent ... not really a projection at all */ double a, /* major axis or radius if es==0 */ a_orig, /* major axis before any +proj related adjustment */ es, /* e ^ 2 */ es_orig, /* es before any +proj related adjustment */ e, /* eccentricity */ ra, /* 1/A */ one_es, /* 1 - e^2 */ rone_es, /* 1/one_es */ lam0, phi0, /* central longitude, latitude */ x0, y0, /* easting and northing */ k0, /* general scaling factor */ to_meter, fr_meter; /* cartesian scaling */ int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */ double datum_params[7]; struct _pj_gi **gridlist; int gridlist_count; int has_geoid_vgrids; struct _pj_gi **vgridlist_geoid; int vgridlist_geoid_count; double vto_meter, vfr_meter; double from_greenwich; /* prime meridian offset (in radians) */ double long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/ int is_long_wrap_set; char axis[4]; #ifdef PROJ_PARMS__ PROJ_PARMS__ #endif /* end of optional extensions */ } PJ; /* public API */ #include "proj_api.h" /* Generate pj_list external or make list from include file */ #ifndef PJ_LIST_H extern struct PJ_LIST pj_list[]; #else #define PROJ_HEAD(id, name) \ struct PJconsts *pj_##id(struct PJconsts*); extern char * const pj_s_##id; #ifndef lint #define DO_PJ_LIST_ID #endif #include PJ_LIST_H #ifndef lint #undef DO_PJ_LIST_ID #endif #undef PROJ_HEAD #define PROJ_HEAD(id, name) {#id, pj_##id, &pj_s_##id}, struct PJ_LIST pj_list[] = { #include PJ_LIST_H {0, 0, 0}, }; #undef PROJ_HEAD #endif #ifndef PJ_ELLPS__ extern struct PJ_ELLPS pj_ellps[]; #endif #ifndef PJ_UNITS__ extern struct PJ_UNITS pj_units[]; #endif #ifndef PJ_DATUMS__ extern struct PJ_DATUMS pj_datums[]; extern struct PJ_PRIME_MERIDIANS pj_prime_meridians[]; #endif #ifdef PJ_LIB__ /* repeatative projection code */ #define PROJ_HEAD(id, name) static const char des_##id [] = name #define ENTRYA(name) \ C_NAMESPACE_VAR const char * const pj_s_##name = des_##name; \ C_NAMESPACE PJ *pj_##name(PJ *P) { if (!P) { \ if( (P = (PJ*) pj_malloc(sizeof(PJ))) != NULL) { \ memset( P, 0, sizeof(PJ) ); \ P->pfree = freeup; P->fwd = 0; P->inv = 0; \ P->spc = 0; P->descr = des_##name; #define ENTRYX } return P; } else { #define ENTRY0(name) ENTRYA(name) ENTRYX #define ENTRY1(name, a) ENTRYA(name) P->a = 0; ENTRYX #define ENTRY2(name, a, b) ENTRYA(name) P->a = 0; P->b = 0; ENTRYX #define ENDENTRY(p) } return (p); } #define E_ERROR(err) { pj_ctx_set_errno( P->ctx, err); freeup(P); return(0); } #define E_ERROR_0 { freeup(P); return(0); } #define F_ERROR { pj_ctx_set_errno( P->ctx, -20); return(xy); } #define I_ERROR { pj_ctx_set_errno( P->ctx, -20); return(lp); } #define FORWARD(name) static XY name(LP lp, PJ *P) { XY xy = {0.0,0.0} #define INVERSE(name) static LP name(XY xy, PJ *P) { LP lp = {0.0,0.0} #define FREEUP static void freeup(PJ *P) { #define SPECIAL(name) static void name(LP lp, PJ *P, struct FACTORS *fac) #endif #define MAX_TAB_ID 80 typedef struct { float lam, phi; } FLP; typedef struct { int lam, phi; } ILP; struct CTABLE { char id[MAX_TAB_ID]; /* ascii info */ LP ll; /* lower left corner coordinates */ LP del; /* size of cells */ ILP lim; /* limits of conversion matrix */ FLP *cvs; /* conversion matrix */ }; typedef struct _pj_gi { char *gridname; /* identifying name of grid, eg "conus" or ntv2_0.gsb */ char *filename; /* full path to filename */ const char *format; /* format of this grid, ie "ctable", "ntv1", "ntv2" or "missing". */ int grid_offset; /* offset in file, for delayed loading */ struct CTABLE *ct; struct _pj_gi *next; struct _pj_gi *child; } PJ_GRIDINFO; /* procedure prototypes */ double dmstor(const char *, char **); double dmstor_ctx(projCtx ctx, const char *, char **); void set_rtodms(int, int); char *rtodms(char *, double, int, int); double adjlon(double); double aacos(projCtx,double), aasin(projCtx,double), asqrt(double), aatan2(double, double); PVALUE pj_param(projCtx ctx, paralist *, const char *); paralist *pj_mkparam(char *); int pj_ell_set(projCtx ctx, paralist *, double *, double *); int pj_datum_set(projCtx,paralist *, PJ *); int pj_prime_meridian_set(paralist *, PJ *); int pj_angular_units_set(paralist *, PJ *); paralist *pj_clone_paralist( const paralist* ); paralist*pj_search_initcache( const char *filekey ); void pj_insert_initcache( const char *filekey, const paralist *list); double *pj_enfn(double); double pj_mlfn(double, double, double, double *); double pj_inv_mlfn(projCtx, double, double, double *); double pj_qsfn(double, double, double); double pj_tsfn(double, double, double); double pj_msfn(double, double, double); double pj_phi2(projCtx, double, double); double pj_qsfn_(double, PJ *); double *pj_authset(double); double pj_authlat(double, double *); COMPLEX pj_zpoly1(COMPLEX, COMPLEX *, int); COMPLEX pj_zpolyd1(COMPLEX, COMPLEX *, int, COMPLEX *); FILE *pj_open_lib(projCtx, char *, char *); int pj_deriv(LP, double, PJ *, struct DERIVS *); int pj_factors(LP, PJ *, double, struct FACTORS *); struct PW_COEF {/* row coefficient structure */ int m; /* number of c coefficients (=0 for none) */ double *c; /* power coefficients */ }; /* Approximation structures and procedures */ typedef struct { /* Chebyshev or Power series structure */ projUV a, b; /* power series range for evaluation */ /* or Chebyshev argument shift/scaling */ struct PW_COEF *cu, *cv; int mu, mv; /* maximum cu and cv index (+1 for count) */ int power; /* != 0 if power series, else Chebyshev */ } Tseries; Tseries *mk_cheby(projUV, projUV, double, projUV *, projUV (*)(projUV), int, int, int); projUV bpseval(projUV, Tseries *); projUV bcheval(projUV, Tseries *); projUV biveval(projUV, Tseries *); void *vector1(int, int); void **vector2(int, int, int); void freev2(void **v, int nrows); int bchgen(projUV, projUV, int, int, projUV **, projUV(*)(projUV)); int bch2bps(projUV, projUV, projUV **, int, int); /* nadcon related protos */ LP nad_intr(LP, struct CTABLE *); LP nad_cvt(LP, int, struct CTABLE *); struct CTABLE *nad_init(projCtx ctx, char *); struct CTABLE *nad_ctable_init( projCtx ctx, FILE * fid ); int nad_ctable_load( projCtx ctx, struct CTABLE *, FILE * fid ); struct CTABLE *nad_ctable2_init( projCtx ctx, FILE * fid ); int nad_ctable2_load( projCtx ctx, struct CTABLE *, FILE * fid ); void nad_free(struct CTABLE *); /* higher level handling of datum grid shift files */ int pj_apply_vgridshift( PJ *defn, const char *listname, PJ_GRIDINFO ***gridlist_p, int *gridlist_count_p, int inverse, long point_count, int point_offset, double *x, double *y, double *z ); int pj_apply_gridshift_2( PJ *defn, int inverse, long point_count, int point_offset, double *x, double *y, double *z ); int pj_apply_gridshift_3( projCtx ctx, PJ_GRIDINFO **gridlist, int gridlist_count, int inverse, long point_count, int point_offset, double *x, double *y, double *z ); PJ_GRIDINFO **pj_gridlist_from_nadgrids( projCtx, const char *, int * ); void pj_deallocate_grids(); PJ_GRIDINFO *pj_gridinfo_init( projCtx, const char * ); int pj_gridinfo_load( projCtx, PJ_GRIDINFO * ); void pj_gridinfo_free( projCtx, PJ_GRIDINFO * ); void *proj_mdist_ini(double); double proj_mdist(double, double, double, const void *); double proj_inv_mdist(projCtx ctx, double, const void *); void *pj_gauss_ini(double, double, double *,double *); LP pj_gauss(projCtx, LP, const void *); LP pj_inv_gauss(projCtx, LP, const void *); extern char const pj_release[]; struct PJ_ELLPS *pj_get_ellps_ref( void ); struct PJ_DATUMS *pj_get_datums_ref( void ); struct PJ_UNITS *pj_get_units_ref( void ); struct PJ_LIST *pj_get_list_ref( void ); struct PJ_PRIME_MERIDIANS *pj_get_prime_meridians_ref( void ); #ifndef DISABLE_CVSID # if defined(__GNUC__) && __GNUC__ >= 4 # define PJ_CVSID(string) static char pj_cvsid[] __attribute__((used)) = string; # else # define PJ_CVSID(string) static char pj_cvsid[] = string; \ static char *cvsid_aw() { return( cvsid_aw() ? ((char *) NULL) : pj_cvsid ); } # endif #else # define PJ_CVSID(string) #endif #ifdef __cplusplus } #endif #endif /* end of basic projections header */ Geo-Proj4-1.09/ChangeLog0000644000175000001440000000706413231664747015465 0ustar00markovusers00000000000000== Revision history for Perl extension Geo::Proj4. All modifications where created by Mark Overmeer, unless explicitly stated differently. version 1.09: Tue 23 Jan 17:59:12 CET 2018 Improvements: - convert to GIT - publish via GitHUB - rename Changes into ChangeLog version 1.08: Thu 28 Dec 11:38:06 CET 2017 Fixes: - revert change of 1.07, because it breaks people's code, and make it harder to use transform() rt.cpan.org#123950 [Salven Rezic] version 1.07: Wed 8 Nov 10:57:23 CET 2017 Fixes: - z-coordinates in transform rt.cpan.org#121300 [Peter Daen] version 1.06: Thu 23 Feb 10:24:01 CET 2017 Fixes: - NO_ERROR renamed: name conflict on mingw32/Windows 10 reported by [James P. Rushworth] - do not symlink on windows - crash on list functions from example, caused by a stack overflow. reported by [James P. Rushworth] version 1.05: Tue Jan 21 14:32:06 CET 2014 Improvements: - change documentation style. version 1.04: Fri Sep 7 12:54:23 CEST 2012 Fixes: - proj4 version 4.8.0 does not install project.h anymore. Therefore, we carry our own now. Flagged by [Jeff Huber] version 1.03: Wed Feb 8 19:57:47 CET 2012 Fixes: - \ missing in pattern match of ::projection() rt.cpan.org#74774 [Heiko Klein] version 1.02: Wed Nov 23 09:24:16 CET 2011 Fixes: - with Perl 14.2, the XS compile flags changed slightly causing a Dynaloader error. rt.cpan.org#72626 [Dirk Stöcker] Improvements: - a little better installation under Windows [André Joost] version 1.01: Tue Jan 27 16:41:47 CET 2009 - show ->new(init => ) example in main man-page. Contributed by [Michael R. Davis] - improved output of examples/test_list.pl - do not list latlong/longlat/geocent as projections, because "proj -l" doesn't either. - tested with 4.6.1 version 1.00: Thu Oct 2 23:27:31 CEST 2008 - XS should use Safefree(), not free(). Marvellous fix by rt.cpan.org#39749 [Dan Stahlke] version 0.99: Fri Jun 8 17:08:40 CEST 2007 - EPGS -> EPSG in example script [Michael R. Davis] - added t/pod.t version 0.98: Fri Mar 9 14:16:09 CET 2007 - moved eg/ to examples/, probably easier to find. - added examples/use_epsg.pl, and use of epgs files in synopsis. Thanks to [Michael R. Davis] Translated POD in script to text, to avoid search.cpan.org to index it as package documentation. - converted production of manual pages to use oodist, which eliminated the need for the mkdist, mkdoc, version files, but added PODTAIL.txt and text to Makefile.PL - renamed test_list into examples/test_list.pl - removed use of ppport.h, which is probably not used. - added documentation for the two error messages. version 0.97: Sat Nov 4 12:14:22 CET 2006 - Avoid double free() on DESTROY by simply forgetting to free the memory. Of course this leaks, which should be fixed in next release. version 0.96: Mon Dec 12 11:58:18 CET 2005 - added projection() and datum() - renamed or datum(), ellipsoid(), and unit() into ....Info() version 0.95: Fri Nov 25 17:27:21 CET 2005 (public release) - minor doc improvements version 0.12: Sat Nov 19 10:37:45 CET 2005 (internal release) - new maintainer: Mark Overmeer - converted ExtUtils::MakeMaker in Makefile.PL - moved Proj4.pm to lib/Geo/Proj4 - create manual page with OODoc, to be able to integrate it with Geo::Point docs. - So many extensions!!!! version 0.11: Sat Mar 27 15:52:42 PST 2004 - Fixed build errors in typemap with more current versions of gcc. - Switched Makefile.PL to use Module::Install. version 0.10: Sat Mar 27 03:44:33 PST 2004 - Initial cut of Geo::Proj4. Geo-Proj4-1.09/Proj4.xs0000644000175000001440000001661613231664747015270 0ustar00markovusers00000000000000#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include #include "projects.h" #include MODULE = Geo::Proj4 PACKAGE = Geo::Proj4 #define PROJ4_NO_ERROR "no error" int libproj_version_proj4() CODE: RETVAL = PJ_VERSION; OUTPUT: RETVAL void new_proj4(defn) char * defn INIT: projPJ rawstruct; PPCODE: rawstruct = pj_init_plus(defn); if(rawstruct==NULL) { EXTEND(SP, 3); PUSHs(&PL_sv_undef); PUSHs(sv_2mortal(newSViv(pj_errno))); PUSHs(sv_2mortal(newSVpv(pj_strerrno(pj_errno),0))); } else { SV *object = newSV(0); sv_setref_pv(object, "Geo::Proj4", (void *)rawstruct); XPUSHs(sv_2mortal(object)); } SV * forward_degrees_proj4(proj, lat, lon) projPJ proj double lat double lon PROTOTYPE: $$$ PREINIT: projUV in, out; PPCODE: in.u = lon * DEG_TO_RAD; in.v = lat * DEG_TO_RAD; out = pj_fwd(in, proj); if(out.u == HUGE_VAL && out.v == HUGE_VAL) XSRETURN_UNDEF; EXTEND(SP, 2); if(pj_is_latlong(proj)) { PUSHs(sv_2mortal(newSVnv(out.u * RAD_TO_DEG))); PUSHs(sv_2mortal(newSVnv(out.v * RAD_TO_DEG))); } else { PUSHs(sv_2mortal(newSVnv(out.u))); PUSHs(sv_2mortal(newSVnv(out.v))); } SV * forward_proj4(proj, lat, lon) projPJ proj double lat double lon PROTOTYPE: $$$ PREINIT: projUV in, out; projPJ toProj; PPCODE: in.u = lon; in.v = lat; out = pj_fwd(in, proj); if (out.u == HUGE_VAL && out.v == HUGE_VAL) XSRETURN_UNDEF; EXTEND(SP, 2); PUSHs(sv_2mortal(newSVnv(out.u))); PUSHs(sv_2mortal(newSVnv(out.v))); SV * inverse_degrees_proj4(proj, x, y) projPJ proj double x double y PROTOTYPE: $$$ PREINIT: projUV in, out; PPCODE: if(pj_is_latlong(proj)) { in.u = x * DEG_TO_RAD; in.v = y * DEG_TO_RAD; } else { in.u = x; in.v = y; } out = pj_inv(in, proj); if (out.u == HUGE_VAL && out.v == HUGE_VAL) XSRETURN_UNDEF; EXTEND(SP, 2); PUSHs(sv_2mortal(newSVnv(out.v * RAD_TO_DEG))); PUSHs(sv_2mortal(newSVnv(out.u * RAD_TO_DEG))); SV * inverse_proj4(proj, x, y) projPJ proj double x double y PROTOTYPE: $$$ PREINIT: projUV in, out; PPCODE: in.u = x; in.v = y; out = pj_inv(in, proj); if (out.u == HUGE_VAL && out.v == HUGE_VAL) XSRETURN_UNDEF; EXTEND(SP, 2); PUSHs(sv_2mortal(newSVnv(out.v))); PUSHs(sv_2mortal(newSVnv(out.u))); void transform_proj4(proj_from, proj_to, points, degrees) projPJ proj_from projPJ proj_to SV * points bool degrees PROTOTYPE: $$$$ INIT: double *x; double *y; double *z; AV * res; AV * retlist; I32 nrpoints = 0; I32 p; if( (!SvROK(points)) || (SvTYPE(SvRV(points)) != SVt_PVAV) || ((nrpoints = av_len((AV *)SvRV(points))) < 0) ) { XSRETURN_UNDEF; } nrpoints += 1; /* XS returns last index, not size */ PPCODE: New(0, x, nrpoints, double); New(0, y, nrpoints, double); New(0, z, nrpoints, double); /* fprintf(stderr, "%d points\n", nrpoints); */ for(p = 0; p < nrpoints; p++) { AV * point = (AV *)SvRV(*av_fetch((AV *)SvRV(points), p, 0)); x[p] = SvNV(*av_fetch(point, 0, 0)); y[p] = SvNV(*av_fetch(point, 1, 0)); z[p] = av_len(point) < 2 ? 0.0 : SvNV(*av_fetch(point, 2, 0)); /* fprintf(stderr, "point=%f %f %f\n", x[p], y[p], z[p]); */ if(degrees && pj_is_latlong(proj_from)) { x[p] *= DEG_TO_RAD; y[p] *= DEG_TO_RAD; } } if(pj_transform(proj_from, proj_to, nrpoints, 0, x, y, z)==0) { XPUSHs(sv_2mortal(newSViv(0))); XPUSHs(sv_2mortal(newSVpv(PROJ4_NO_ERROR, 0))); retlist = (AV *)sv_2mortal((SV *)newAV()); for(p=0; p < nrpoints; p++) { AV * res = (AV *)sv_2mortal((SV *)newAV()); if(degrees && pj_is_latlong(proj_to)) { x[p] *= RAD_TO_DEG; y[p] *= RAD_TO_DEG; } av_push(res, newSVnv(x[p])); av_push(res, newSVnv(y[p])); if(z[p]!=0.0) av_push(res, newSVnv(z[p])); av_push(retlist, newRV((SV *)res)); } XPUSHs(newRV_noinc((SV *)retlist)); } else { XPUSHs(sv_2mortal(newSViv(pj_errno))); XPUSHs(sv_2mortal(newSVpv(pj_strerrno(pj_errno),0))); } Safefree(x); Safefree(y); Safefree(z); int has_inverse_proj4(proj) projPJ proj PROTOTYPE: $ CODE: RETVAL = (proj->inv ? 1 : 0); OUTPUT: RETVAL int is_latlong_proj4(proj) projPJ proj PROTOTYPE: $ CODE: RETVAL = (pj_is_latlong(proj) ? 1 : 0); OUTPUT: RETVAL int is_geocentric_proj4(proj) projPJ proj PROTOTYPE: $ CODE: RETVAL = (pj_is_geocent(proj) ? 1 : 0); OUTPUT: RETVAL SV * def_types_proj4(void) PREINIT: struct PJ_LIST *type; PPCODE: #if PJ_VERSION >= 449 for(type = pj_get_list_ref(); type->id; type++) { /* same as "proj -l" does */ if( strcmp(type->id,"latlong")==0 || strcmp(type->id,"longlat")==0 || strcmp(type->id,"geocent")==0 ) continue; XPUSHs(sv_2mortal(newSVpv(type->id, 0))); } #endif SV * type_proj4(id) char * id PREINIT: struct PJ_LIST *type; PPCODE: #if PJ_VERSION >= 449 for(type = pj_get_list_ref(); type->id; type++) { if(strcmp(id, type->id)!=0) continue; XPUSHs(sv_2mortal(newSVpv(*type->descr, 0))); break; } #endif SV * def_ellps_proj4(void) PREINIT: struct PJ_ELLPS *ellps; PPCODE: #if PJ_VERSION >= 449 for(ellps = pj_get_ellps_ref(); ellps->id; ellps++) { XPUSHs(sv_2mortal(newSVpv(ellps->id, 0))); } #endif SV * ellps_proj4(id) char * id PREINIT: struct PJ_ELLPS *ellps; PPCODE: #if PJ_VERSION >= 449 for(ellps = pj_get_ellps_ref(); ellps->id; ellps++) { if(strcmp(id, ellps->id)!=0) continue; XPUSHs(sv_2mortal(newSVpv(ellps->major, 0))); XPUSHs(sv_2mortal(newSVpv(ellps->ell, 0))); XPUSHs(sv_2mortal(newSVpv(ellps->name, 0))); break; } #endif SV * def_units_proj4(void) PREINIT: struct PJ_UNITS *unit; PPCODE: #if PJ_VERSION >= 449 for(unit = pj_get_units_ref(); unit->id; unit++) { XPUSHs(sv_2mortal(newSVpv(unit->id, 0))); } #endif SV * unit_proj4(id) char * id PREINIT: struct PJ_UNITS *units; PPCODE: #if PJ_VERSION >= 449 for(units = pj_get_units_ref(); units->id; units++) { if(strcmp(id, units->id)!=0) continue; XPUSHs(sv_2mortal(newSVpv(units->to_meter, 0))); XPUSHs(sv_2mortal(newSVpv(units->name, 0))); break; } #endif SV * def_datums_proj4(void) PREINIT: struct PJ_DATUMS *datum; PPCODE: #if PJ_VERSION >= 449 for(datum = pj_get_datums_ref(); datum->id; datum++) { XPUSHs(sv_2mortal(newSVpv(datum->id, 0))); } #endif SV * datum_proj4(id) char * id PREINIT: struct PJ_DATUMS *datum; PPCODE: #if PJ_VERSION >= 449 for(datum = pj_get_datums_ref(); datum->id; datum++) { if(strcmp(id, datum->id)!=0) continue; XPUSHs(sv_2mortal(newSVpv(datum->ellipse_id, 0))); XPUSHs(sv_2mortal(newSVpv(datum->defn, 0))); if(datum->comments!=NULL && strlen(datum->comments)) { XPUSHs(sv_2mortal(newSVpv(datum->comments, 0))); } break; } #endif void dump_proj4(proj) projPJ proj PROTOTYPE: $ CODE: pj_pr_list(proj); SV * normalized_proj4(proj) projPJ proj PROTOTYPE: $ CODE: RETVAL = newSVpv(pj_get_def(proj, 0), 0); OUTPUT: RETVAL void DESTROY(proj) projPJ proj PROTOTYPE: $ CODE: /* cloned objects also call DESTROY, which is a very */ /* bad idea. Therefore, the memory will not be freed */ /* until a major rewrite avoids this problem. */ /* pj_free(proj); */ Geo-Proj4-1.09/xt/0000755000175000001440000000000013231664750014331 5ustar00markovusers00000000000000Geo-Proj4-1.09/xt/99pod.t0000644000175000001440000000041213231664747015465 0ustar00markovusers00000000000000#!/usr/bin/perl use warnings; use strict; use Test::More; BEGIN { eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; plan skip_all => "devel home uses OODoc" if $ENV{MARKOV_DEVEL}; } all_pod_files_ok(); Geo-Proj4-1.09/Makefile.PL0000644000175000001440000000410013231664747015651 0ustar00markovusers00000000000000use ExtUtils::MakeMaker; require 5.006; # increased per release my $relversion = '1.09'; my $libversion = '4.4.9'; # Should also work when you do not have FWTools installed... my $FWTools = $ENV{GEOPROJ_FWTOOLS_DIR} || $ENV{FWTOOLS_DIR} # windows || '.'; # This is part is very UNIX/Linux centric. Please help me with the # required windows tests. my $FWbin = "$FWTools/bin_safe"; my $cs2cs = -x "$FWbin/cs2cs" ? "$FWbin/cs2cs" : 'cs2cs'; open CS, "$cs2cs 2>&1 |" or die "ERROR: proj library not found, where is cs2cs?\n"; my $got = ; $got =~ m/\ ([\d.]+)\,/ or die "ERROR: proj library version not known\n"; my $version = $1; $version ge $libversion or die "ERROR: libproj too old, found $version required is $libversion\n"; if($^O ne 'MSWin32' && $^O ne 'cygwin') { unlink 'projects.h'; my $own_projects = "src/$version/projects.h"; if(-f $own_projects) { symlink $own_projects, 'projects.h' or die "ERROR: cannot install $own_projects: $!\n"; warn "installed $own_projects\n"; } } WriteMakefile ( NAME => 'Geo::Proj4' , VERSION => $relversion , AUTHOR => 'Mark Overmeer' , ABSTRACT => 'Proj4 library for carthographic projections' , INC => "-I$FWTools/include -I." , LIBS => [ "-L$FWTools/lib -lproj" ] , LICENSE => 'perl' , META_MERGE => { 'meta-spec' => { version => 2 } , resources => { repository => { type => 'git' , url => 'https://github.com/markov2/perl5-Geo-Proj4.git' , web => 'https://github.com/markov2/perl5-Geo-Proj4' } } , homepage => 'http://perl.overmeer.net/CPAN/' , license => [ 'http://dev.perl.org/licenses/' ] } ); ### used by oodist during production of this distribution sub MY::postamble { <<'__POSTAMBLE' } # for DIST, see PODTAIL.txt as well RAWDIR = ../public_html/geo-proj4/raw DISTDIR = ../public_html/geo-proj4/source __POSTAMBLE Geo-Proj4-1.09/README0000644000175000001440000000141613231664747014566 0ustar00markovusers00000000000000=== README for Geo-Proj4 version 1.09 = Generated on Tue Jan 23 17:59:19 2018 by OODoc 2.02 There are various ways to install this module: (1) if you have a command-line, you can do: perl -MCPAN -e 'install ' (2) if you use Windows, have a look at http://ppm.activestate.com/ (3) if you have downloaded this module manually (as root/administrator) gzip -d Geo-Proj4-1.09.tar.gz tar -xf Geo-Proj4-1.09.tar cd Geo-Proj4-1.09 perl Makefile.PL make # optional make test # optional make install For usage, see the included manual-pages or http://search.cpan.org/dist/Geo-Proj4-1.09/ Please report problems to http://rt.cpan.org/Dist/Display.html?Queue=Geo-Proj4 Geo-Proj4-1.09/META.yml0000644000175000001440000000117613231664750015154 0ustar00markovusers00000000000000--- abstract: 'Proj4 library for carthographic projections' author: - 'Mark Overmeer' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Geo-Proj4 no_index: directory: - t - inc resources: repository: https://github.com/markov2/perl5-Geo-Proj4.git version: '1.09' x_homepage: http://perl.overmeer.net/CPAN/ x_serialization_backend: 'CPAN::Meta::YAML version 0.011' Geo-Proj4-1.09/META.json0000644000175000001440000000212213231664750015314 0ustar00markovusers00000000000000{ "abstract" : "Proj4 library for carthographic projections", "author" : [ "Mark Overmeer" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.3, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5", "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Geo-Proj4", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } } }, "release_status" : "stable", "resources" : { "repository" : { "type" : "git", "url" : "https://github.com/markov2/perl5-Geo-Proj4.git", "web" : "https://github.com/markov2/perl5-Geo-Proj4" } }, "version" : "1.09", "x_homepage" : "http://perl.overmeer.net/CPAN/", "x_serialization_backend" : "JSON::PP version 2.94" }