proj-4.9.3/ 0000755 0000000 0000000 00000000000 12761101671 007452 5 0000000 0000000 proj-4.9.3/install-sh 0000755 0000000 0000000 00000035463 12761101557 011414 0000000 0000000 #!/bin/sh
# install - install a program, script, or datafile
scriptversion=2014-09-12.12; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# 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
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
tab=' '
nl='
'
IFS=" $tab$nl"
# Set DOITPROG to "echo" to test this script.
doit=${DOITPROG-}
doit_exec=${doit:-exec}
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
is_target_a_directory=possibly
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
dstdir=`dirname "$dst"`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
# $RANDOM is not portable (e.g. dash); use it when possible to
# lower collision chance
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
# As "mkdir -p" follows symlinks and we work in /tmp possibly; so
# create the $tmpdir first (and fail if unsuccessful) to make sure
# that nobody tries to guess the $tmpdir name.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
oIFS=$IFS
IFS=/
set -f
set fnord $dstdir
shift
set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
proj-4.9.3/depcomp 0000755 0000000 0000000 00000056016 12761101662 010757 0000000 0000000 #! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva .
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to .
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# Get the directory component of the given path, and save it in the
# global variables '$dir'. Note that this directory component will
# be either empty or ending with a '/' character. This is deliberate.
set_dir_from ()
{
case $1 in
*/*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
*) dir=;;
esac
}
# Get the suffix-stripped basename of the given path, and save it the
# global variable '$base'.
set_base_from ()
{
base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
}
# If no dependency file was actually created by the compiler invocation,
# we still have to create a dummy depfile, to avoid errors with the
# Makefile "include basename.Plo" scheme.
make_dummy_depfile ()
{
echo "#dummy" > "$depfile"
}
# Factor out some common post-processing of the generated depfile.
# Requires the auxiliary global variable '$tmpdepfile' to be set.
aix_post_process_depfile ()
{
# If the compiler actually managed to produce a dependency file,
# post-process it.
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependency.h'.
# Do two passes, one to just change these to
# $object: dependency.h
# and one to simply output
# dependency.h:
# which is needed to avoid the deleted-header problem.
{ sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
} > "$depfile"
rm -f "$tmpdepfile"
else
make_dummy_depfile
fi
}
# A tabulation character.
tab=' '
# A newline character.
nl='
'
# Character ranges might be problematic outside the C locale.
# These definitions help.
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lower=abcdefghijklmnopqrstuvwxyz
digits=0123456789
alpha=${upper}${lower}
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Avoid interferences from the environment.
gccflag= dashmflag=
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
## (see the conditional assignment to $gccflag above).
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say). Also, it might not be
## supported by the other compilers which use the 'gcc' depmode.
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The second -e expression handles DOS-style file names with drive
# letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
| tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
aix_post_process_depfile
;;
tcc)
# tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
# FIXME: That version still under development at the moment of writing.
# Make that this statement remains true also for stable, released
# versions.
# It will wrap lines (doesn't matter whether long or short) with a
# trailing '\', as in:
#
# foo.o : \
# foo.c \
# foo.h \
#
# It will put a trailing '\' even on the last line, and will use leading
# spaces rather than leading tabs (at least since its commit 0394caf7
# "Emit spaces for -MD").
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
# We have to change lines of the first kind to '$object: \'.
sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
# And for each line of the second kind, we have to emit a 'dep.h:'
# dummy dependency, to avoid the deleted-header problem.
sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
## The order of this option in the case statement is important, since the
## shell code in configure will try each of these formats in the order
## listed in this file. A plain '-MD' option would be understood by many
## compilers, so we must ensure this comes after the gcc and icc options.
pgcc)
# Portland's C compiler understands '-MD'.
# Will always output deps to 'file.d' where file is the root name of the
# source file under compilation, even if file resides in a subdirectory.
# The object file name does not affect the name of the '.d' file.
# pgcc 10.2 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\' :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
set_dir_from "$object"
# Use the source, not the object, to determine the base name, since
# that's sadly what pgcc will do too.
set_base_from "$source"
tmpdepfile=$base.d
# For projects that build the same source file twice into different object
# files, the pgcc approach of using the *source* file root name can cause
# problems in parallel builds. Use a locking strategy to avoid stomping on
# the same $tmpdepfile.
lockdir=$base.d-lock
trap "
echo '$0: caught signal, cleaning up...' >&2
rmdir '$lockdir'
exit 1
" 1 2 13 15
numtries=100
i=$numtries
while test $i -gt 0; do
# mkdir is a portable test-and-set.
if mkdir "$lockdir" 2>/dev/null; then
# This process acquired the lock.
"$@" -MD
stat=$?
# Release the lock.
rmdir "$lockdir"
break
else
# If the lock is being held by a different process, wait
# until the winning process is done or we timeout.
while test -d "$lockdir" && test $i -gt 0; do
sleep 1
i=`expr $i - 1`
done
fi
i=`expr $i - 1`
done
trap - 1 2 13 15
if test $i -le 0; then
echo "$0: failed to acquire lock after $numtries attempts" >&2
echo "$0: check lockdir '$lockdir'" >&2
exit 1
fi
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
make_dummy_depfile
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
set_dir_from "$object"
set_base_from "$object"
if test "$libtool" = yes; then
# Libtool generates 2 separate objects for the 2 libraries. These
# two compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir$base.o.d # libtool 1.5
tmpdepfile2=$dir.libs/$base.o.d # Likewise.
tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -ne 0; then
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
# Same post-processing that is required for AIX mode.
aix_post_process_depfile
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test $stat -ne 0; then
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this sed invocation
# correctly. Breaking it into two sed invocations is a workaround.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process the last invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed '1,2d' "$tmpdepfile" \
| tr ' ' "$nl" \
| sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E \
| sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
| sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
proj-4.9.3/AUTHORS 0000644 0000000 0000000 00000000613 12761101536 010442 0000000 0000000 Original Author:
Gerald Evenden
Maintainer(s):
Frank Warmerdam
Howard Butler
Contributors:
Brent Fraser
Chris Stuber
Craig Bruce
Victor Osipkov
Andrea Antonello
Charles Karney
Karsten Engsager
Knud Poder
proj-4.9.3/NEWS 0000644 0000000 0000000 00000020420 12761101536 010067 0000000 0000000 4.9.2 Release Notes
-------------------
o proj_def.dat was missing from source distribution
see https://github.com/OSGeo/proj.4/issues/274 for more detail
o Update Geodesic library from GeographicLib
o Remove setlocale() use in pj_init_ctx()
o Renamed PVALUE in pj_param.c to prevent clash with Windows
4.9.1 Release Notes
-------------------
o 4.9.0RC2 release was abandoned because it was not promoted in a
timely fashion. Subsequent maintenance of tickets has continued,
and a new 4.9.1 release was issued in its place.
o Implement inverse solution for Winkel Tripel from Drazan Tutic #250
o More CMake configuration tweaks. The CMake configuration is probably
not at feature parity with the autotools builds at this point but it
is converging #256
o Tweak initialization ordering around setlocal which may have caused
issues #237
o Support out-of-tree autoconf builds more completely #247
o Fix NaN handling by geod_inverse and geod_polygon_addedge #251 & #253
o Update config.sub and config.guess #257
o Adapt Charles Karney's CMake patches for smoother build #258
o Define default PROJ_LIB location for CMake compilation #261
o Fix Windows compilation on PJ_aitoff.c
o Align CMake SOVERSION with autotools #263
o Regenerate nad/epsg with GDAL r28536 to avoid precision loss in TOWGS84
parameters, e.g. on Amersfoort / RD EPSG:4289 (#260)
o Add CMake project-config.cmake scripts (#264 from Charles Karney)
o Dial back test sensitivity #255
4.9.0 Release Notes
-------------------
o Implement CMake as an option for building PROJ.4
o Implement new virtual file api (projFileAPI) so that all access to grid
shift and init files can be hooked.
o Replace geodesic implementation with one from Charles Karney and add a
supported public interface (geodesic.h).
o Upgraded to EPSG 8.5.
o Removed old (deprecated) Java bindings in favor of the new api introduced
in 4.8.0.
o Implement the calcofi (Cal Coop Ocean Fish Invest Lines/Stations) projection
o Install projects.h again for applications that want access to internal
structures and functions despite the inherent fragility.
o Various bug fixes and cleanup.
o Added the CalCOFI pseudo-projection, #135
4.8.0 Release Notes
-------------------
o Added the Natural Earth projection.
o Added HEALPIX, rHEALPIX and Icosahedral Snyder Equal Area projections.
o nad2bin now produces "CTable2" format grid shift files by default which
are platform independent.
o nad2nad removed, use cs2cs for datum shift operations.
o projects.h no longer installed as a public include file. Please try to
only use proj_api.h.
o Add pj_get_spheroid_defn() accessor.
o Added an alternate version of pj_init() that takes a projCtx (execution
context) structure to address multithreading issues with error management
and to provide a support for application hookable error reporting and
logging.
o Upgrade to EPSG 7.9. Some changes in ideal datum selection.
o JNI bindings reworked, org.proj4.Projections deprecated in favor of
org.proj4.PJ.
o Added preliminary vertical datum support.
o Fix various multithreading issues, particular in datum grid handling code.
o Added support for the +axis= option for alternate axis orientations as
part of a coordinate system (used for TM South Orientated support).
o +proj=omerc implementatioin replaced with code from libproj4. +rot_conv
flag no longer works, and some coordinate systems (ie. Malaysian) will
need to use +gamma instead. "epsg" init file updated accordingly.
4.7.0 Release Notes
-------------------
o Added in memory caching of init file search results for substantial
acceleration in some application environments (like MapServer).
o Regenerated nad/epsg init file with EPSG 7.1 database, including new
support for Google Mercator (EPSG:3857).
o Various thread safety improvements, including preliminary support for
a mutex lock around some operations, like grid loading.
4.6.1 Release Notes
-------------------
o Upgraded to EPSG 6.17 version for nad/epsg. Also corrected the precision
problem introduced in the last version.
o Added logic for tmerc projection to fail rather than return crazy results
if more than 90 degrees away from the central meridian (#5). This change
may only be temporary till a more comprehensive solution is found.
o Fixed handling of extra text in cs2cs.
o Renamed INSTALL to INSTALL.TXT.
o The eqc projection has been generalized to include a latitude of origin.
o Added the glabsgm (Gauss Laborde / Sphere Geometric Mean) projection,
and gstmerc variation.
o nad/IGNF init catalogue created.
o added the ntf_r93.gsb datum shift file.
o Add /Op in nmake.opt compile options to avoid VC7 optimization bug (#12)
o Fix testvarious test script so it works properly when grid files available
4.6.0 Release Notes
-------------------
o MAJOR: Rework pj_transform() to avoid applying ellipsoid to ellipsoid
transformations as a datum shift when no datum info is available.
o Avoid applying "change of ellipsoid" during datum shifting based on
ellipsoids getting changed to spheres for spherical projections.
o Upgrade to EPSG 6.13
o Added "900913" "Google Mercator" code in nad/esri.extra.
o Avoid some static variable based multi-threading problems.
o Improve error recovery if ctable style datum shift grid fails to load.
o Support drive letters properly in PROJ_LIB paths for win32.
o Fix occasional problem with DMS parsing.
o Removed non-functional mpoly projection.
o add lonlat, and latlon as aliases for longlat.
4.5.0 Release Notes
-------------------
o Microsoft Visual Studio 8 compatibility changes.
o Upgraded to EPSG 6.11.1 database.
o Several bug fixes to pj_transform() to handle transient errors properly.
o Fix Krovak projection (include +czech flag)
o Added Roussilhe Stereographic projection from libproj4 (proj=rouss).
o Added experimental +lon_wrap flag for alternate pj_transform() longitude
wrapping behavior on output.
4.4.9 Release Notes
-------------------
o Win32 build uses proj.dll by default now.
o Added accessor functions for the datums, ellps, prime_meridians, units and
main projection definition lists so they can be used on windows where
data objects exported from the DLL don't work easily.
o Added JNI (Java Native Interface) support within the jniwrap directory,
and some supporting entry points directly in the proj dll/so. See
--with-jni configure switch, and jniwrap/README.
o Added the proj=stereoa and proj=geos projections, incorporated from
Gerald's libproj4.
o A few other bug fixes.
4.4.8 Release Notes
-------------------
o Updated epsg file to EPSG 6.5, added other.extra pseudo-EPSG WMS definitions
o Made significant fixes to prime meridian support.
o Substantially change pj_datum_transform(), so it and pj_transform() will
work between coordinate systems with different ellipsoids but no datum
shift information (assume +towgs84=0,0,0).
o Added pj_get_release() function.
o Ensure pj_transform() will try to transform all points in provided list if
even some might transform properly.
o Improved the accuracy of Geocentric_To_Geodetic() via an iterative
solution.
o Various other bug fixes.
4.4.7 Release Notes
-------------------
o Added NTv2 (.gsb) grid shift file support.
o Modified datum shift support so that data file data is only loaded if
needed. Also added 'null' grid as a fallback option, and support for
making grids optional (prefix with '@' in +nadgrids).
o Regenerated nad/epsg file with towgs84 parameters for non-greenwich prime
meridians.
o Updated nad/esri file with better generated form from Paul Ramsey.
o Various bug fixes.
4.4.6 Release Notes
-------------------
o Incorporated new lcca (Lambert Conformal Conic Alternate) projection from
Gerald.
o Updated 'espg' translation file for EPSG 6.2.2 with better support for
prime meridians.
o Added Prime Meridians via +pm command switch to cs2cs (and pj_transform).
o Fixed bug with 7 parameter transforms.
o Added 'esri' pseudo-epsg coordinate system file.
o Cleanup so that PROJ.4 compiles clean as C++ code.
o Added pj_get_def() to expand definitions of stuff like +init clauses.
o Added a Krovak implementation (proj=krov). Note this may change again
in the next release.
proj-4.9.3/INSTALL 0000644 0000000 0000000 00000017227 12761101536 010434 0000000 0000000 Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.
proj-4.9.3/makefile.vc 0000644 0000000 0000000 00000000713 12761101536 011502 0000000 0000000 #
# NMAKE Makefile to build PROJ.4 on Windows
#
# This makefile.vc delegates making targets to src\makefile.vc
# so it's just a thin wrapper.
#
MAKE = nmake
RM = -del
default:
cd src
$(MAKE) /f makefile.vc
cd ..\nad
$(MAKE) /f makefile.vc
cd ..
clean:
cd src
$(MAKE) /f makefile.vc clean
cd ..\nad
$(MAKE) /f makefile.vc clean
cd ..
install-all:
cd src
$(MAKE) /f makefile.vc install
cd ..\nad
$(MAKE) /f makefile.vc install-all
cd ..
proj-4.9.3/aclocal.m4 0000644 0000000 0000000 00000124511 12761101666 011242 0000000 0000000 # generated automatically by aclocal 1.15 -*- Autoconf -*-
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
[m4_warning([this file was generated for autoconf 2.69.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
# Copyright (C) 2002-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.15'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.15], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
# _AM_AUTOCONF_VERSION(VERSION)
# -----------------------------
# aclocal traces this macro to find the Autoconf version.
# This is a private macro too. Using m4_define simplifies
# the logic in aclocal, which can simply ignore this definition.
m4_define([_AM_AUTOCONF_VERSION], [])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.15])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to
# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
#
# Of course, Automake must honor this variable whenever it calls a
# tool from the auxiliary directory. The problem is that $srcdir (and
# therefore $ac_aux_dir as well) can be either absolute or relative,
# depending on how configure is run. This is pretty annoying, since
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
# source directory, any form will work fine, but in subdirectories a
# relative path needs to be adjusted first.
#
# $ac_aux_dir/missing
# fails when called from a subdirectory if $ac_aux_dir is relative
# $top_srcdir/$ac_aux_dir/missing
# fails if $ac_aux_dir is absolute,
# fails when called from a subdirectory in a VPATH build with
# a relative $ac_aux_dir
#
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
# are both prefixed by $srcdir. In an in-source build this is usually
# harmless because $srcdir is '.', but things will broke when you
# start a VPATH build or use an absolute $srcdir.
#
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
# and then we would define $MISSING as
# MISSING="\${SHELL} $am_aux_dir/missing"
# This will work as long as MISSING is not called from configure, because
# unfortunately $(top_srcdir) has no meaning in configure.
# However there are other variables, like CC, which are often used in
# configure, and could therefore not use this "fixed" $ac_aux_dir.
#
# Another solution, used here, is to always expand $ac_aux_dir to an
# absolute PATH. The drawback is that using absolute paths prevent a
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
# Expand $ac_aux_dir to an absolute path.
am_aux_dir=`cd "$ac_aux_dir" && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ([2.52])dnl
m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])dnl
AC_SUBST([$1_FALSE])dnl
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
m4_define([_AM_COND_VALUE_$1], [$2])dnl
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
# dependency, and given that the user is not expected to run this macro,
# just rely on AC_PROG_CC.
AC_DEFUN([_AM_DEPENDENCIES],
[AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
m4_if([$1], [CC], [depcc="$CC" am_compiler_list=],
[$1], [CXX], [depcc="$CXX" am_compiler_list=],
[$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
[$1], [UPC], [depcc="$UPC" am_compiler_list=],
[$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named 'D' -- because '-MD' means "put the output
# in D".
rm -rf conftest.dir
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
cp "$am_depcomp" conftest.dir
cd conftest.dir
# We will build objects and dependencies in a subdirectory because
# it helps to detect inapplicable dependency modes. For instance
# both Tru64's cc and ICC support -MD to output dependencies as a
# side effect of compilation, but ICC will put the dependencies in
# the current directory while Tru64 will put them in the object
# directory.
mkdir sub
am_cv_$1_dependencies_compiler_type=none
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
fi
am__universal=false
m4_case([$1], [CC],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac],
[CXX],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac])
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
# we should not choose a depcomp mode which is confused by this.
#
# We need to recreate these files for each test, as the compiler may
# overwrite some of them when testing with obscure command lines.
# This happens at least with the AIX C compiler.
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
# Solaris 10 /bin/sh.
echo '/* dummy */' > sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
# We check with '-c' and '-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle '-M -o', and we need to detect this. Also, some Intel
# versions had trouble with output in subdirs.
am__obj=sub/conftest.${OBJEXT-o}
am__minus_obj="-o $am__obj"
case $depmode in
gcc)
# This depmode causes a compiler race in universal mode.
test "$am__universal" = false || continue
;;
nosideeffect)
# After this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested.
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
msvc7 | msvc7msys | msvisualcpp | msvcmsys)
# This compiler won't grok '-c -o', but also, the minuso test has
# not run yet. These depmodes are late enough in the game, and
# so weak that their functioning should not be impacted.
am__obj=conftest.${OBJEXT-o}
am__minus_obj=
;;
none) break ;;
esac
if depmode=$depmode \
source=sub/conftest.c object=$am__obj \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
am_cv_$1_dependencies_compiler_type=$depmode
break
fi
fi
done
cd ..
rm -rf conftest.dir
else
am_cv_$1_dependencies_compiler_type=none
fi
])
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
AM_CONDITIONAL([am__fastdep$1], [
test "x$enable_dependency_tracking" != xno \
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
])
# AM_SET_DEPDIR
# -------------
# Choose a directory name for dependency files.
# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
AC_DEFUN([AM_SET_DEPDIR],
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
])
# AM_DEP_TRACK
# ------------
AC_DEFUN([AM_DEP_TRACK],
[AC_ARG_ENABLE([dependency-tracking], [dnl
AS_HELP_STRING(
[--enable-dependency-tracking],
[do not reject slow dependency extractors])
AS_HELP_STRING(
[--disable-dependency-tracking],
[speeds up one-time build])])
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
am__nodep='_no'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
AC_SUBST([AMDEPBACKSLASH])dnl
_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
AC_SUBST([am__nodep])dnl
_AM_SUBST_NOTMAKE([am__nodep])dnl
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[{
# Older Autoconf quotes --file arguments for eval, but not when files
# are listed without --file. Let's play safe and only enable the eval
# if we detect the quoting.
case $CONFIG_FILES in
*\'*) eval set x "$CONFIG_FILES" ;;
*) set x $CONFIG_FILES ;;
esac
shift
for mf
do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named 'Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# Grep'ing the whole file is not good either: AIX grep has a line
# limit of 2048, but all sed's we know have understand at least 4000.
if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running 'make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "$am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
done
}
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
# AM_OUTPUT_DEPENDENCY_COMMANDS
# -----------------------------
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each '.P' file that we will
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
])
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
m4_define([AC_PROG_CC],
m4_defn([AC_PROG_CC])
[_AM_PROG_CC_C_O
])
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
# The call with PACKAGE and VERSION arguments is the old style
# call (pre autoconf-2.50), which is being phased out. PACKAGE
# and VERSION should now be passed to AC_INIT and removed from
# the call to AM_INIT_AUTOMAKE.
# We support both call styles for the transition. After
# the next Automake release, Autoconf can make the AC_INIT
# arguments mandatory, and then we can depend on a new Autoconf
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.65])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
if test "`cd $srcdir && pwd`" != "`pwd`"; then
# Use -I$(srcdir) only when $(srcdir) != ., so that make's output
# is not polluted with repeated "-I."
AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
# test to see if srcdir already configured
if test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
fi
# test whether we have cygpath
if test -z "$CYGPATH_W"; then
if (cygpath --version) >/dev/null 2>/dev/null; then
CYGPATH_W='cygpath -w'
else
CYGPATH_W=echo
fi
fi
AC_SUBST([CYGPATH_W])
# Define the identity of the package.
dnl Distinguish between old-style and new-style calls.
m4_ifval([$2],
[AC_DIAGNOSE([obsolete],
[$0: two- and three-arguments forms are deprecated.])
m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
AC_SUBST([PACKAGE], [$1])dnl
AC_SUBST([VERSION], [$2])],
[_AM_SET_OPTIONS([$1])dnl
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
m4_if(
m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
[ok:ok],,
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
_AM_IF_OPTION([no-define],,
[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
# Some tools Automake needs.
AC_REQUIRE([AM_SANITY_CHECK])dnl
AC_REQUIRE([AC_ARG_PROGRAM])dnl
AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
AM_MISSING_PROG([AUTOCONF], [autoconf])
AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
AM_MISSING_PROG([AUTOHEADER], [autoheader])
AM_MISSING_PROG([MAKEINFO], [makeinfo])
AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
# For better backward compatibility. To be removed once Automake 1.9.x
# dies out for good. For more background, see:
#
#
AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
# We need awk for the "check" target (and possibly the TAP driver). The
# system "awk" is bad on some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
[_AM_PROG_TAR([v7])])])
_AM_IF_OPTION([no-dependencies],,
[AC_PROVIDE_IFELSE([AC_PROG_CC],
[_AM_DEPENDENCIES([CC])],
[m4_define([AC_PROG_CC],
m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[_AM_DEPENDENCIES([CXX])],
[m4_define([AC_PROG_CXX],
m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
AC_PROVIDE_IFELSE([AC_PROG_OBJC],
[_AM_DEPENDENCIES([OBJC])],
[m4_define([AC_PROG_OBJC],
m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
[_AM_DEPENDENCIES([OBJCXX])],
[m4_define([AC_PROG_OBJCXX],
m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
])
AC_REQUIRE([AM_SILENT_RULES])dnl
dnl The testsuite driver may need to know about EXEEXT, so add the
dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
AC_CONFIG_COMMANDS_PRE(dnl
[m4_provide_if([_AM_COMPILER_EXEEXT],
[AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
# POSIX will say in a future version that running "rm -f" with no argument
# is OK; and we want to be able to make that assumption in our Makefile
# recipes. So use an aggressive probe to check that the usage we want is
# actually supported "in the wild" to an acceptable degree.
# See automake bug#10828.
# To make any issue more visible, cause the running configure to be aborted
# by default if the 'rm' program in use doesn't match our expectations; the
# user can still override this though.
if rm -f && rm -fr && rm -rf; then : OK; else
cat >&2 <<'END'
Oops!
Your 'rm' program seems unable to run without file operands specified
on the command line, even when the '-f' option is present. This is contrary
to the behaviour of most rm programs out there, and not conforming with
the upcoming POSIX standard:
Please tell bug-automake@gnu.org about your system, including the value
of your $PATH and any error possibly output before this message. This
can help us improve future automake versions.
END
if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
echo 'Configuration will proceed anyway, since you have set the' >&2
echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
echo >&2
else
cat >&2 <<'END'
Aborting the configuration process, to ensure you take notice of the issue.
You can download and install GNU coreutils to get an 'rm' implementation
that behaves properly: .
If you want to complete the configuration process using your problematic
'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
to "yes", and re-run configure.
END
AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
fi
fi
dnl The trailing newline in this macro's definition is deliberate, for
dnl backward compatibility and to allow trailing 'dnl'-style comments
dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
])
dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
dnl mangled by Autoconf and run in a shell conditional statement.
m4_define([_AC_COMPILER_EXEEXT],
m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
# loop where config.status creates the headers, so we can generate
# our stamp files there.
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
[# Compute $1's index in $config_headers.
_am_arg=$1
_am_stamp_count=1
for _am_header in $config_headers :; do
case $_am_header in
$_am_arg | $_am_arg:* )
break ;;
* )
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
esac
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_SH
# ------------------
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
if test x"${install_sh+set}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
*)
install_sh="\${SHELL} $am_aux_dir/install-sh"
esac
fi
AC_SUBST([install_sh])])
# Copyright (C) 2003-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# Check whether the underlying file-system supports filenames
# with a leading dot. For instance MS-DOS doesn't.
AC_DEFUN([AM_SET_LEADING_DOT],
[rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_MAKE_INCLUDE()
# -----------------
# Check to see how make treats includes.
AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo this is the am__doit target
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
AC_MSG_CHECKING([for style of include used by $am_make])
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# Ignore all kinds of additional output from 'make'.
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=include
am__quote=
_am_result=GNU
;;
esac
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=.include
am__quote="\""
_am_result=BSD
;;
esac
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_MISSING_PROG(NAME, PROGRAM)
# ------------------------------
AC_DEFUN([AM_MISSING_PROG],
[AC_REQUIRE([AM_MISSING_HAS_RUN])
$1=${$1-"${am_missing_run}$2"}
AC_SUBST($1)])
# AM_MISSING_HAS_RUN
# ------------------
# Define MISSING if not defined so far and test if it is modern enough.
# If it is, set am_missing_run to use it, otherwise, to nothing.
AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([missing])dnl
if test x"${MISSING+set}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
*)
MISSING="\${SHELL} $am_aux_dir/missing" ;;
esac
fi
# Use eval to expand $SHELL
if eval "$MISSING --is-lightweight"; then
am_missing_run="$MISSING "
else
am_missing_run=
AC_MSG_WARN(['missing' script is too old or missing])
fi
])
# -*- Autoconf -*-
# Obsolete and "removed" macros, that must however still report explicit
# error messages when used, to smooth transition.
#
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
AC_DEFUN([AM_CONFIG_HEADER],
[AC_DIAGNOSE([obsolete],
['$0': this macro is obsolete.
You should use the 'AC][_CONFIG_HEADERS' macro instead.])dnl
AC_CONFIG_HEADERS($@)])
AC_DEFUN([AM_PROG_CC_STDC],
[AC_PROG_CC
am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc
AC_DIAGNOSE([obsolete],
['$0': this macro is obsolete.
You should simply use the 'AC][_PROG_CC' macro instead.
Also, your code should no longer depend upon 'am_cv_prog_cc_stdc',
but upon 'ac_cv_prog_cc_stdc'.])])
AC_DEFUN([AM_C_PROTOTYPES],
[AC_FATAL([automatic de-ANSI-fication support has been removed])])
AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_MANGLE_OPTION(NAME)
# -----------------------
AC_DEFUN([_AM_MANGLE_OPTION],
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
# _AM_SET_OPTION(NAME)
# --------------------
# Set option NAME. Presently that only means defining a flag for this option.
AC_DEFUN([_AM_SET_OPTION],
[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
# _AM_SET_OPTIONS(OPTIONS)
# ------------------------
# OPTIONS is a space-separated list of Automake options.
AC_DEFUN([_AM_SET_OPTIONS],
[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
# -------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_PROG_CC_C_O
# ---------------
# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC
# to automatically call this.
AC_DEFUN([_AM_PROG_CC_C_O],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([compile])dnl
AC_LANG_PUSH([C])dnl
AC_CACHE_CHECK(
[whether $CC understands -c and -o together],
[am_cv_prog_cc_c_o],
[AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
# Make sure it works both with $CC and with simple cc.
# Following AC_PROG_CC_C_O, we do the test twice because some
# compilers refuse to overwrite an existing .o file with -o,
# though they will create one.
am_cv_prog_cc_c_o=yes
for am_i in 1 2; do
if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
&& test -f conftest2.$ac_objext; then
: OK
else
am_cv_prog_cc_c_o=no
break
fi
done
rm -f core conftest*
unset am_i])
if test "$am_cv_prog_cc_c_o" != yes; then
# Losing compiler, so override with the script.
# FIXME: It is wrong to rewrite CC.
# But if we don't then we get into trouble of one sort or another.
# A longer-term fix would be to have automake use am__CC in this case,
# and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
CC="$am_aux_dir/compile $CC"
fi
AC_LANG_POP([C])])
# For backward compatibility.
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_RUN_LOG(COMMAND)
# -------------------
# Run COMMAND, save the exit status in ac_status, and log it.
# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
AC_DEFUN([AM_RUN_LOG],
[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
(exit $ac_status); }])
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_SANITY_CHECK
# ---------------
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Reject unsafe characters in $srcdir or the absolute working directory
# name. Accept space and tab only in the latter.
am_lf='
'
case `pwd` in
*[[\\\"\#\$\&\'\`$am_lf]]*)
AC_MSG_ERROR([unsafe absolute working directory name]);;
esac
case $srcdir in
*[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
esac
# Do 'set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
am_has_slept=no
for am_try in 1 2; do
echo "timestamp, slept: $am_has_slept" > conftest.file
set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
if test "$[*]" = "X"; then
# -L didn't work.
set X `ls -t "$srcdir/configure" conftest.file`
fi
if test "$[*]" != "X $srcdir/configure conftest.file" \
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
if test "$[2]" = conftest.file || test $am_try -eq 2; then
break
fi
# Just in case.
sleep 1
am_has_slept=yes
done
test "$[2]" = conftest.file
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
AC_MSG_RESULT([yes])
# If we didn't sleep, we still need to ensure time stamps of config.status and
# generated files are strictly newer.
am_sleep_pid=
if grep 'slept: no' conftest.file >/dev/null 2>&1; then
( sleep 1 ) &
am_sleep_pid=$!
fi
AC_CONFIG_COMMANDS_PRE(
[AC_MSG_CHECKING([that generated files are newer than configure])
if test -n "$am_sleep_pid"; then
# Hide warnings about reused PIDs.
wait $am_sleep_pid 2>/dev/null
fi
AC_MSG_RESULT([done])])
rm -f conftest.file
])
# Copyright (C) 2009-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_SILENT_RULES([DEFAULT])
# --------------------------
# Enable less verbose build rules; with the default set to DEFAULT
# ("yes" being less verbose, "no" or empty being verbose).
AC_DEFUN([AM_SILENT_RULES],
[AC_ARG_ENABLE([silent-rules], [dnl
AS_HELP_STRING(
[--enable-silent-rules],
[less verbose build output (undo: "make V=1")])
AS_HELP_STRING(
[--disable-silent-rules],
[verbose build output (undo: "make V=0")])dnl
])
case $enable_silent_rules in @%:@ (((
yes) AM_DEFAULT_VERBOSITY=0;;
no) AM_DEFAULT_VERBOSITY=1;;
*) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
esac
dnl
dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
dnl do not support nested variable expansions.
dnl See automake bug#9928 and bug#10237.
am_make=${MAKE-make}
AC_CACHE_CHECK([whether $am_make supports nested variables],
[am_cv_make_support_nested_variables],
[if AS_ECHO([['TRUE=$(BAR$(V))
BAR0=false
BAR1=true
V=1
am__doit:
@$(TRUE)
.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
am_cv_make_support_nested_variables=yes
else
am_cv_make_support_nested_variables=no
fi])
if test $am_cv_make_support_nested_variables = yes; then
dnl Using '$V' instead of '$(V)' breaks IRIX make.
AM_V='$(V)'
AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
else
AM_V=$AM_DEFAULT_VERBOSITY
AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
fi
AC_SUBST([AM_V])dnl
AM_SUBST_NOTMAKE([AM_V])dnl
AC_SUBST([AM_DEFAULT_V])dnl
AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
AM_BACKSLASH='\'
AC_SUBST([AM_BACKSLASH])dnl
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
])
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_STRIP
# ---------------------
# One issue with vendor 'install' (even GNU) is that you can't
# specify the program used to strip binaries. This is especially
# annoying in cross-compiling environments, where the build's strip
# is unlikely to handle the host's binaries.
# Fortunately install-sh will honor a STRIPPROG variable, so we
# always use install-sh in "make install-strip", and initialize
# STRIPPROG with the value of the STRIP variable (set by the user).
AC_DEFUN([AM_PROG_INSTALL_STRIP],
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
# Installed binaries are usually stripped using 'strip' when the user
# run "make install-strip". However 'strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the 'STRIP' environment variable to overrule this program.
dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
if test "$cross_compiling" != no; then
AC_CHECK_TOOL([STRIP], [strip], :)
fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Copyright (C) 2006-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
# This macro is traced by Automake.
AC_DEFUN([_AM_SUBST_NOTMAKE])
# AM_SUBST_NOTMAKE(VARIABLE)
# --------------------------
# Public sister of _AM_SUBST_NOTMAKE.
AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_PROG_TAR(FORMAT)
# --------------------
# Check how to create a tarball in format FORMAT.
# FORMAT should be one of 'v7', 'ustar', or 'pax'.
#
# Substitute a variable $(am__tar) that is a command
# writing to stdout a FORMAT-tarball containing the directory
# $tardir.
# tardir=directory && $(am__tar) > result.tar
#
# Substitute a variable $(am__untar) that extract such
# a tarball read from stdin.
# $(am__untar) < result.tar
#
AC_DEFUN([_AM_PROG_TAR],
[# Always define AMTAR for backward compatibility. Yes, it's still used
# in the wild :-( We should find a proper way to deprecate it ...
AC_SUBST([AMTAR], ['$${TAR-tar}'])
# We'll loop over all known methods to create a tar archive until one works.
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
m4_if([$1], [v7],
[am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
[m4_case([$1],
[ustar],
[# The POSIX 1988 'ustar' format is defined with fixed-size fields.
# There is notably a 21 bits limit for the UID and the GID. In fact,
# the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
# and bug#13588).
am_max_uid=2097151 # 2^21 - 1
am_max_gid=$am_max_uid
# The $UID and $GID variables are not portable, so we need to resort
# to the POSIX-mandated id(1) utility. Errors in the 'id' calls
# below are definitely unexpected, so allow the users to see them
# (that is, avoid stderr redirection).
am_uid=`id -u || echo unknown`
am_gid=`id -g || echo unknown`
AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
if test $am_uid -le $am_max_uid; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
_am_tools=none
fi
AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
if test $am_gid -le $am_max_gid; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
_am_tools=none
fi],
[pax],
[],
[m4_fatal([Unknown tar format])])
AC_MSG_CHECKING([how to create a $1 tar archive])
# Go ahead even if we have the value already cached. We do so because we
# need to set the values for the 'am__tar' and 'am__untar' variables.
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
for _am_tool in $_am_tools; do
case $_am_tool in
gnutar)
for _am_tar in tar gnutar gtar; do
AM_RUN_LOG([$_am_tar --version]) && break
done
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
am__untar="$_am_tar -xf -"
;;
plaintar)
# Must skip GNU tar: if it does not support --format= it doesn't create
# ustar tarball either.
(tar --version) >/dev/null 2>&1 && continue
am__tar='tar chf - "$$tardir"'
am__tar_='tar chf - "$tardir"'
am__untar='tar xf -'
;;
pax)
am__tar='pax -L -x $1 -w "$$tardir"'
am__tar_='pax -L -x $1 -w "$tardir"'
am__untar='pax -r'
;;
cpio)
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
am__untar='cpio -i -H $1 -d'
;;
none)
am__tar=false
am__tar_=false
am__untar=false
;;
esac
# If the value was cached, stop now. We just wanted to have am__tar
# and am__untar set.
test -n "${am_cv_prog_tar_$1}" && break
# tar/untar a dummy directory, and stop if the command works.
rm -rf conftest.dir
mkdir conftest.dir
echo GrepMe > conftest.dir/file
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
rm -rf conftest.dir
if test -s conftest.tar; then
AM_RUN_LOG([$am__untar /dev/null 2>&1 && break
fi
done
rm -rf conftest.dir
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
m4_include([m4/ax_cflags_warn_all.m4])
m4_include([m4/libtool.m4])
m4_include([m4/ltoptions.m4])
m4_include([m4/ltsugar.m4])
m4_include([m4/ltversion.m4])
m4_include([m4/lt~obsolete.m4])
proj-4.9.3/Makefile.in 0000644 0000000 0000000 00000065660 12761101666 011460 0000000 0000000 # Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
$(am__configure_deps) $(am__DIST_COMMON)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/proj_config.h
CONFIG_CLEAN_FILES = proj.pc
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(pkgconfigdir)"
DATA = $(pkgconfig_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
cscope distdir dist dist-all distcheck
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/proj.pc.in AUTHORS \
COPYING ChangeLog INSTALL NEWS README compile config.guess \
config.sub depcomp install-sh ltmain.sh missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
if test -d "$(distdir)"; then \
find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -rf "$(distdir)" \
|| { sleep 5 && rm -rf "$(distdir)"; }; \
else :; fi
am__post_remove_distdir = $(am__remove_distdir)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
DIST_ARCHIVES = $(distdir).tar.gz $(distdir).zip
GZIP_ENV = --best
DIST_TARGETS = dist-gzip dist-zip
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
C_WFLAGS = @C_WFLAGS@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
JNI_INCLUDE = @JNI_INCLUDE@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MUTEX_SETTING = @MUTEX_SETTING@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
THREAD_LIB = @THREAD_LIB@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = src man nad jniwrap cmake
EXTRA_DIST = makefile.vc nmake.opt CMakeLists.txt
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = proj.pc
AUTOMAKE_OPTIONS = dist-zip
ACLOCAL_AMFLAGS = -I m4
all: all-recursive
.SUFFIXES:
am--refresh: Makefile
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
$(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
$(am__cd) $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
$(am__aclocal_m4_deps):
proj.pc: $(top_builddir)/config.status $(srcdir)/proj.pc.in
cd $(top_builddir) && $(SHELL) ./config.status $@
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool config.lt
install-pkgconfigDATA: $(pkgconfig_DATA)
@$(NORMAL_INSTALL)
@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \
done
uninstall-pkgconfigDATA:
@$(NORMAL_UNINSTALL)
@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir)
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscope: cscope.files
test ! -s cscope.files \
|| $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
clean-cscope:
-rm -f cscope.files
cscope.files: clean-cscope cscopelist
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
distdir: $(DISTFILES)
$(am__remove_distdir)
test -d "$(distdir)" || mkdir "$(distdir)"
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
-test -n "$(am__skip_mode_fix)" \
|| find "$(distdir)" -type d ! -perm -755 \
-exec chmod u+rwx,go+rx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__post_remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
$(am__post_remove_distdir)
dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
$(am__post_remove_distdir)
dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)
dist-tarZ: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__post_remove_distdir)
dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__post_remove_distdir)
dist dist-all:
$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
$(am__post_remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
*.tar.xz*) \
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir)
chmod u+w $(distdir)
mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
chmod a-w $(distdir)
test -d $(distdir)/_build || exit 0; \
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build/sub \
&& ../../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=../.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
&& cd "$$am__cwd" \
|| exit 1
$(am__post_remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@test -n '$(distuninstallcheck_dir)' || { \
echo 'ERROR: trying to run $@ with an empty' \
'$$(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
$(am__cd) '$(distuninstallcheck_dir)' || { \
echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile $(DATA)
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(pkgconfigdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool \
distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
html-am:
info: info-recursive
info-am:
install-data-am: install-pkgconfigDATA
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-recursive
install-html-am:
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-pkgconfigDATA
.MAKE: $(am__recursive_targets) install-am install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
am--refresh check check-am clean clean-cscope clean-generic \
clean-libtool cscope cscopelist-am ctags ctags-am dist \
dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \
dist-xz dist-zip distcheck distclean distclean-generic \
distclean-libtool distclean-tags distcleancheck distdir \
distuninstallcheck dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-pkgconfigDATA install-ps \
install-ps-am install-strip installcheck installcheck-am \
installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
uninstall-am uninstall-pkgconfigDATA
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
proj-4.9.3/src/ 0000755 0000000 0000000 00000000000 12761101671 010241 5 0000000 0000000 proj-4.9.3/src/adjlon.c 0000644 0000000 0000000 00000000707 12761101536 011600 0000000 0000000 /* reduce argument to range +/- PI */
#include
#include
#define SPI 3.14159265359
#define TWOPI 6.2831853071795864769
#define ONEPI 3.14159265358979323846
double adjlon (double lon) {
if (fabs(lon) <= SPI) return( lon );
lon += ONEPI; /* adjust to 0..2pi rad */
lon -= TWOPI * floor(lon / TWOPI); /* remove integral # of 'revolutions'*/
lon -= ONEPI; /* adjust back to -pi..pi rad */
return( lon );
}
proj-4.9.3/src/biveval.c 0000644 0000000 0000000 00000004350 12761101536 011757 0000000 0000000 /* procedures for evaluating Tseries */
# include
# define NEAR_ONE 1.00001
static double ceval(struct PW_COEF *C, int n, projUV w, projUV w2) {
double d=0, dd=0, vd, vdd, tmp, *c;
int j;
for (C += n ; n-- ; --C ) {
if ( (j = C->m) != 0) {
vd = vdd = 0.;
for (c = C->c + --j; j ; --j ) {
vd = w2.v * (tmp = vd) - vdd + *c--;
vdd = tmp;
}
d = w2.u * (tmp = d) - dd + w.v * vd - vdd + 0.5 * *c;
} else
d = w2.u * (tmp = d) - dd;
dd = tmp;
}
if ( (j = C->m) != 0 ) {
vd = vdd = 0.;
for (c = C->c + --j; j ; --j ) {
vd = w2.v * (tmp = vd) - vdd + *c--;
vdd = tmp;
}
return (w.u * d - dd + 0.5 * ( w.v * vd - vdd + 0.5 * *c ));
} else
return (w.u * d - dd);
}
projUV /* bivariate Chebyshev polynomial entry point */
bcheval(projUV in, Tseries *T) {
projUV w2, w;
projUV out;
/* scale to +-1 */
w.u = ( in.u + in.u - T->a.u ) * T->b.u;
w.v = ( in.v + in.v - T->a.v ) * T->b.v;
if (fabs(w.u) > NEAR_ONE || fabs(w.v) > NEAR_ONE) {
out.u = out.v = HUGE_VAL;
pj_errno = -36;
} else { /* double evaluation */
w2.u = w.u + w.u;
w2.v = w.v + w.v;
out.u = ceval(T->cu, T->mu, w, w2);
out.v = ceval(T->cv, T->mv, w, w2);
}
return out;
}
projUV /* bivariate power polynomial entry point */
bpseval(projUV in, Tseries *T) {
projUV out;
double *c, row;
int i, m;
out.u = out.v = 0.;
for (i = T->mu; i >= 0; --i) {
row = 0.;
if ((m = T->cu[i].m) != 0) {
c = T->cu[i].c + m;
while (m--)
row = *--c + in.v * row;
}
out.u = row + in.u * out.u;
}
for (i = T->mv; i >= 0; --i) {
row = 0.;
if ((m = T->cv[i].m) != 0) {
c = T->cv[i].c + m;
while (m--)
row = *--c + in.v * row;
}
out.v = row + in.u * out.v;
}
return out;
}
projUV /* general entry point selecting evaluation mode */
biveval(projUV in, Tseries *T) {
if (T->power) {
return bpseval(in, T);
} else {
return bcheval(in, T);
}
}
proj-4.9.3/src/pj_qsfn.c 0000644 0000000 0000000 00000000521 12761101536 011763 0000000 0000000 /* determine small q */
#include
#include
# define EPSILON 1.0e-7
double
pj_qsfn(double sinphi, double e, double one_es) {
double con;
if (e >= EPSILON) {
con = e * sinphi;
return (one_es * (sinphi / (1. - con * con) -
(.5 / e) * log ((1. - con) / (1. + con))));
} else
return (sinphi + sinphi);
}
proj-4.9.3/src/dmstor.c 0000644 0000000 0000000 00000004551 12761101536 011642 0000000 0000000 /* Convert DMS string to radians */
#include
#include
#include
static double proj_strtod(char *nptr, char **endptr);
/* following should be sufficient for all but the rediculous */
#define MAX_WORK 64
static const char
*sym = "NnEeSsWw";
static const double
vm[] = {
DEG_TO_RAD,
.0002908882086657216,
.0000048481368110953599
};
double
dmstor(const char *is, char **rs) {
return dmstor_ctx( pj_get_default_ctx(), is, rs );
}
double
dmstor_ctx(projCtx ctx, const char *is, char **rs) {
int sign, n, nl;
char *p, *s, work[MAX_WORK];
double v, tv;
if (rs)
*rs = (char *)is;
/* copy sting into work space */
while (isspace(sign = *is)) ++is;
for (n = MAX_WORK, s = work, p = (char *)is; isgraph(*p) && --n ; )
*s++ = *p++;
*s = '\0';
/* it is possible that a really odd input (like lots of leading
zeros) could be truncated in copying into work. But ... */
sign = *(s = work);
if (sign == '+' || sign == '-') s++;
else sign = '+';
for (v = 0., nl = 0 ; nl < 3 ; nl = n + 1 ) {
if (!(isdigit(*s) || *s == '.')) break;
if ((tv = proj_strtod(s, &s)) == HUGE_VAL)
return tv;
switch (*s) {
case 'D': case 'd':
n = 0; break;
case '\'':
n = 1; break;
case '"':
n = 2; break;
case 'r': case 'R':
if (nl) {
pj_ctx_set_errno( ctx, -16 );
return HUGE_VAL;
}
++s;
v = tv;
goto skip;
default:
v += tv * vm[nl];
skip: n = 4;
continue;
}
if (n < nl) {
pj_ctx_set_errno( ctx, -16 );
return HUGE_VAL;
}
v += tv * vm[n];
++s;
}
/* postfix sign */
if (*s && (p = strchr(sym, *s))) {
sign = (p - sym) >= 4 ? '-' : '+';
++s;
}
if (sign == '-')
v = -v;
if (rs) /* return point of next char after valid string */
*rs = (char *)is + (s - work);
return v;
}
static double
proj_strtod(char *nptr, char **endptr)
{
char c, *cp = nptr;
double result;
/*
* Scan for characters which cause problems with VC++ strtod()
*/
while ((c = *cp) != '\0') {
if (c == 'd' || c == 'D') {
/*
* Found one, so NUL it out, call strtod(),
* then restore it and return
*/
*cp = '\0';
result = strtod(nptr, endptr);
*cp = c;
return result;
}
++cp;
}
/* no offending characters, just handle normally */
return pj_strtod(nptr, endptr);
}
proj-4.9.3/src/PJ_poly.c 0000644 0000000 0000000 00000012043 12761101536 011701 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(poly, "Polyconic (American)")
"\n\tConic, Sph&Ell";
struct pj_opaque {
double ml0; \
double *en;
};
#define TOL 1e-10
#define CONV 1e-10
#define N_ITER 10
#define I_ITER 20
#define ITOL 1.e-12
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double ms, sp, cp;
if (fabs(lp.phi) <= TOL) {
xy.x = lp.lam;
xy.y = -Q->ml0;
} else {
sp = sin(lp.phi);
ms = fabs(cp = cos(lp.phi)) > TOL ? pj_msfn(sp, cp, P->es) / sp : 0.;
xy.x = ms * sin(lp.lam *= sp);
xy.y = (pj_mlfn(lp.phi, sp, cp, Q->en) - Q->ml0) + ms * (1. - cos(lp.lam));
}
return xy;
}
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double cot, E;
if (fabs(lp.phi) <= TOL) {
xy.x = lp.lam;
xy.y = Q->ml0;
} else {
cot = 1. / tan(lp.phi);
xy.x = sin(E = lp.lam * sin(lp.phi)) * cot;
xy.y = lp.phi - P->phi0 + cot * (1. - cos(E));
}
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
xy.y += Q->ml0;
if (fabs(xy.y) <= TOL) {
lp.lam = xy.x;
lp.phi = 0.;
} else {
double r, c, sp, cp, s2ph, ml, mlb, mlp, dPhi;
int i;
r = xy.y * xy.y + xy.x * xy.x;
for (lp.phi = xy.y, i = I_ITER; i ; --i) {
sp = sin(lp.phi);
s2ph = sp * ( cp = cos(lp.phi));
if (fabs(cp) < ITOL)
I_ERROR;
c = sp * (mlp = sqrt(1. - P->es * sp * sp)) / cp;
ml = pj_mlfn(lp.phi, sp, cp, Q->en);
mlb = ml * ml + r;
mlp = P->one_es / (mlp * mlp * mlp);
lp.phi += ( dPhi =
( ml + ml + c * mlb - 2. * xy.y * (c * ml + 1.) ) / (
P->es * s2ph * (mlb - 2. * xy.y * ml) / c +
2.* (xy.y - ml) * (c * mlp - 1. / s2ph) - mlp - mlp ));
if (fabs(dPhi) <= ITOL)
break;
}
if (!i)
I_ERROR;
c = sin(lp.phi);
lp.lam = asin(xy.x * tan(lp.phi) * sqrt(1. - P->es * c * c)) / sin(lp.phi);
}
return lp;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
double B, dphi, tp;
int i;
if (fabs(xy.y = P->phi0 + xy.y) <= TOL) {
lp.lam = xy.x;
lp.phi = 0.;
} else {
lp.phi = xy.y;
B = xy.x * xy.x + xy.y * xy.y;
i = N_ITER;
do {
tp = tan(lp.phi);
lp.phi -= (dphi = (xy.y * (lp.phi * tp + 1.) - lp.phi -
.5 * ( lp.phi * lp.phi + B) * tp) /
((lp.phi - xy.y) / tp - 1.));
} while (fabs(dphi) > CONV && --i);
if (! i) I_ERROR;
lp.lam = asin(xy.x * tan(lp.phi)) / sin(lp.phi);
}
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
if (P->opaque->en)
pj_dealloc (P->opaque->en);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(poly) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
if (P->es) {
if (!(Q->en = pj_enfn(P->es))) E_ERROR_0;
Q->ml0 = pj_mlfn(P->phi0, sin(P->phi0), cos(P->phi0), Q->en);
P->inv = e_inverse;
P->fwd = e_forward;
} else {
Q->ml0 = -P->phi0;
P->inv = s_inverse;
P->fwd = s_forward;
}
return P;
}
#ifndef PJ_SELFTEST
int pj_poly_selftest (void) {return 0;}
#else
int pj_poly_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=poly +ellps=GRS80 +lat_1=0.5 +lat_2=2"};
char s_args[] = {"+proj=poly +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222605.285770237475, 110642.194561440483},
{ 222605.285770237475, -110642.194561440483},
{-222605.285770237475, 110642.194561440483},
{-222605.285770237475, -110642.194561440483},
};
XY s_fwd_expect[] = {
{ 223368.105210218986, 111769.110491224754},
{ 223368.105210218986, -111769.110491224754},
{-223368.105210218986, 111769.110491224754},
{-223368.105210218986, -111769.110491224754},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.00179663056846135222, 0.000904369476631838518},
{ 0.00179663056846135222, -0.000904369476631838518},
{-0.00179663056846135222, 0.000904369476631838518},
{-0.00179663056846135222, -0.000904369476631838518},
};
LP s_inv_expect[] = {
{ 0.0017904931100023887, 0.000895246554454779222},
{ 0.0017904931100023887, -0.000895246554454779222},
{-0.0017904931100023887, 0.000895246554454779222},
{-0.0017904931100023887, -0.000895246554454779222},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_moll.c 0000644 0000000 0000000 00000013412 12761101536 011662 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(moll, "Mollweide") "\n\tPCyl., Sph.";
PROJ_HEAD(wag4, "Wagner IV") "\n\tPCyl., Sph.";
PROJ_HEAD(wag5, "Wagner V") "\n\tPCyl., Sph.";
#define MAX_ITER 10
#define LOOP_TOL 1e-7
struct pj_opaque {
double C_x, C_y, C_p;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double k, V;
int i;
k = Q->C_p * sin(lp.phi);
for (i = MAX_ITER; i ; --i) {
lp.phi -= V = (lp.phi + sin(lp.phi) - k) /
(1. + cos(lp.phi));
if (fabs(V) < LOOP_TOL)
break;
}
if (!i)
lp.phi = (lp.phi < 0.) ? -M_HALFPI : M_HALFPI;
else
lp.phi *= 0.5;
xy.x = Q->C_x * lp.lam * cos(lp.phi);
xy.y = Q->C_y * sin(lp.phi);
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
lp.phi = aasin(P->ctx, xy.y / Q->C_y);
lp.lam = xy.x / (Q->C_x * cos(lp.phi));
if (fabs(lp.lam) < M_PI) {
lp.phi += lp.phi;
lp.phi = aasin(P->ctx, (lp.phi + sin(lp.phi)) / Q->C_p);
} else {
lp.lam = lp.phi = HUGE_VAL;
}
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
static PJ * setup(PJ *P, double p) {
struct pj_opaque *Q = P->opaque;
double r, sp, p2 = p + p;
P->es = 0;
sp = sin(p);
r = sqrt(M_TWOPI * sp / (p2 + sin(p2)));
Q->C_x = 2. * r / M_PI;
Q->C_y = r / sp;
Q->C_p = p2 + sin(p2);
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
PJ *PROJECTION(moll) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
return setup(P, M_HALFPI);
}
PJ *PROJECTION(wag4) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
return setup(P, M_PI/3.);
}
PJ *PROJECTION(wag5) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
P->es = 0;
Q->C_x = 0.90977;
Q->C_y = 1.65014;
Q->C_p = 3.00896;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_moll_selftest (void) {return 0;}
#else
int pj_moll_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=moll +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{201113.698641813244, 124066.283433859542},
{201113.698641813244, -124066.283433859542},
{-201113.698641813244, 124066.283433859542},
{-201113.698641813244, -124066.283433859542},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{0.00198873782220854774, 0.000806005080362811612},
{0.00198873782220854774, -0.000806005080362811612},
{-0.00198873782220854774, 0.000806005080362811612},
{-0.00198873782220854774, -0.000806005080362811612},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_wag4_selftest (void) {return 0;}
#else
int pj_wag4_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=wag4 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 192801.218662384286, 129416.216394802992},
{ 192801.218662384286, -129416.216394802992},
{-192801.218662384286, 129416.216394802992},
{-192801.218662384286, -129416.216394802992},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00207450259783523421, 0.000772682950537716476},
{ 0.00207450259783523421, -0.000772682950537716476},
{-0.00207450259783523421, 0.000772682950537716476},
{-0.00207450259783523421, -0.000772682950537716476},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_wag5_selftest (void) {return 0;}
#else
int pj_wag5_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=wag5 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 203227.05192532466, 138651.631442713202},
{ 203227.05192532466, -138651.631442713202},
{-203227.05192532466, 138651.631442713202},
{-203227.05192532466, -138651.631442713202},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00196807227086416396, 0.00072121615041701424},
{ 0.00196807227086416396, -0.00072121615041701424},
{-0.00196807227086416396, 0.00072121615041701424},
{-0.00196807227086416396, -0.00072121615041701424},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_putp3.c 0000644 0000000 0000000 00000007137 12761101536 012001 0000000 0000000 #define PJ_LIB__
#include
struct pj_opaque {
double A;
};
PROJ_HEAD(putp3, "Putnins P3") "\n\tPCyl., Sph.";
PROJ_HEAD(putp3p, "Putnins P3'") "\n\tPCyl., Sph.";
#define C 0.79788456
#define RPISQ 0.1013211836
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
xy.x = C * lp.lam * (1. - P->opaque->A * lp.phi * lp.phi);
xy.y = C * lp.phi;
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
lp.phi = xy.y / C;
lp.lam = xy.x / (C * (1. - P->opaque->A * lp.phi * lp.phi));
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(putp3) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->A = 4. * RPISQ;
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
PJ *PROJECTION(putp3p) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->A = 2. * RPISQ;
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_putp3_selftest (void) {return 0;}
#else
int pj_putp3_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=putp3 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 178227.115507793525, 89124.5607860879827},
{ 178227.115507793525, -89124.5607860879827},
{-178227.115507793525, 89124.5607860879827},
{-178227.115507793525, -89124.5607860879827},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00224405032986489889, 0.00112202516475805899},
{ 0.00224405032986489889, -0.00112202516475805899},
{-0.00224405032986489889, 0.00112202516475805899},
{-0.00224405032986489889, -0.00112202516475805899},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_putp3p_selftest (void) {return 0;}
#else
int pj_putp3p_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=putp3p +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 178238.118539984745, 89124.5607860879827},
{ 178238.118539984745, -89124.5607860879827},
{-178238.118539984745, 89124.5607860879827},
{-178238.118539984745, -89124.5607860879827},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00224405032969050844, 0.00112202516475805899},
{ 0.00224405032969050844, -0.00112202516475805899},
{-0.00224405032969050844, 0.00112202516475805899},
{-0.00224405032969050844, -0.00112202516475805899},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_vandg4.c 0000644 0000000 0000000 00000004370 12761101536 012105 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(vandg4, "van der Grinten IV") "\n\tMisc Sph, no inv.";
#define TOL 1e-10
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
double x1, t, bt, ct, ft, bt2, ct2, dt, dt2;
(void) P;
if (fabs(lp.phi) < TOL) {
xy.x = lp.lam;
xy.y = 0.;
} else if (fabs(lp.lam) < TOL || fabs(fabs(lp.phi) - M_HALFPI) < TOL) {
xy.x = 0.;
xy.y = lp.phi;
} else {
bt = fabs(M_TWO_D_PI * lp.phi);
bt2 = bt * bt;
ct = 0.5 * (bt * (8. - bt * (2. + bt2)) - 5.)
/ (bt2 * (bt - 1.));
ct2 = ct * ct;
dt = M_TWO_D_PI * lp.lam;
dt = dt + 1. / dt;
dt = sqrt(dt * dt - 4.);
if ((fabs(lp.lam) - M_HALFPI) < 0.) dt = -dt;
dt2 = dt * dt;
x1 = bt + ct; x1 *= x1;
t = bt + 3.*ct;
ft = x1 * (bt2 + ct2 * dt2 - 1.) + (1.-bt2) * (
bt2 * (t * t + 4. * ct2) +
ct2 * (12. * bt * ct + 4. * ct2) );
x1 = (dt*(x1 + ct2 - 1.) + 2.*sqrt(ft)) /
(4.* x1 + dt2);
xy.x = M_HALFPI * x1;
xy.y = M_HALFPI * sqrt(1. + dt * fabs(x1) - x1 * x1);
if (lp.lam < 0.) xy.x = -xy.x;
if (lp.phi < 0.) xy.y = -xy.y;
}
return xy;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(vandg4) {
P->es = 0.;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_vandg4_selftest (void) {return 0;}
#else
int pj_vandg4_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=vandg4 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223374.57729435508, 111701.19548415358
},
{ 223374.57729435508, -111701.19548415358
},
{-223374.57729435508, 111701.19548415358
},
{-223374.57729435508, -111701.19548415358
},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/pj_apply_gridshift.c 0000644 0000000 0000000 00000023552 12761101536 014215 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Apply datum shifts based on grid shift files (normally NAD27 to
* NAD83 or the reverse). This module is responsible for keeping
* a list of loaded grids, and calling with each one that is
* allowed for a given datum (expressed as the nadgrids= parameter).
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* 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.
*****************************************************************************/
#define PJ_LIB__
#include
#include
#include
/************************************************************************/
/* pj_apply_gridshift() */
/* */
/* This is the externally callable interface - part of the */
/* public API - though it is not used internally any more and I */
/* doubt it is used by any other applications. But we preserve */
/* it to honour our public api. */
/************************************************************************/
int pj_apply_gridshift( projCtx ctx, const char *nadgrids, int inverse,
long point_count, int point_offset,
double *x, double *y, double *z )
{
PJ_GRIDINFO **gridlist;
int grid_count;
int ret;
gridlist = pj_gridlist_from_nadgrids( ctx, nadgrids, &grid_count );
if( gridlist == NULL || grid_count == 0 )
return ctx->last_errno;
ret = pj_apply_gridshift_3( ctx, gridlist, grid_count, inverse,
point_count, point_offset, x, y, z );
/*
** Note this frees the array of grid list pointers, but not the grids
** which is as intended. The grids themselves live on.
*/
pj_dalloc( gridlist );
return ret;
}
/************************************************************************/
/* pj_apply_gridshift_2() */
/* */
/* This implmentation takes uses the gridlist from a coordinate */
/* system definition. If the gridlist has not yet been */
/* populated in the coordinate system definition we set it up */
/* now. */
/************************************************************************/
int pj_apply_gridshift_2( PJ *defn, int inverse,
long point_count, int point_offset,
double *x, double *y, double *z )
{
if( defn->catalog_name != NULL )
return pj_gc_apply_gridshift( defn, inverse, point_count, point_offset,
x, y, z );
if( defn->gridlist == NULL )
{
defn->gridlist =
pj_gridlist_from_nadgrids( pj_get_ctx( defn ),
pj_param(defn->ctx, defn->params,"snadgrids").s,
&(defn->gridlist_count) );
if( defn->gridlist == NULL || defn->gridlist_count == 0 )
return defn->ctx->last_errno;
}
return pj_apply_gridshift_3( pj_get_ctx( defn ),
defn->gridlist, defn->gridlist_count, inverse,
point_count, point_offset, x, y, z );
}
/************************************************************************/
/* pj_apply_gridshift_3() */
/* */
/* This is the real workhorse, given a gridlist. */
/************************************************************************/
int pj_apply_gridshift_3( projCtx ctx, PJ_GRIDINFO **tables, int grid_count,
int inverse, long point_count, int point_offset,
double *x, double *y, double *z )
{
int i;
static int debug_count = 0;
(void) z;
if( tables == NULL || grid_count == 0 )
{
pj_ctx_set_errno( ctx, -38);
return -38;
}
ctx->last_errno = 0;
for( i = 0; i < point_count; i++ )
{
long io = i * point_offset;
LP input, output;
int itable;
input.phi = y[io];
input.lam = x[io];
output.phi = HUGE_VAL;
output.lam = HUGE_VAL;
/* keep trying till we find a table that works */
for( itable = 0; itable < grid_count; itable++ )
{
PJ_GRIDINFO *gi = tables[itable];
struct CTABLE *ct = gi->ct;
double epsilon = (fabs(ct->del.phi)+fabs(ct->del.lam))/10000.0;
/* skip tables that don't match our point at all. */
if( ct->ll.phi - epsilon > input.phi
|| ct->ll.lam - epsilon > input.lam
|| (ct->ll.phi + (ct->lim.phi-1) * ct->del.phi + epsilon
< input.phi)
|| (ct->ll.lam + (ct->lim.lam-1) * ct->del.lam + epsilon
< input.lam) )
continue;
/* If we have child nodes, check to see if any of them apply. */
while( gi->child )
{
PJ_GRIDINFO *child;
for( child = gi->child; child != NULL; child = child->next )
{
struct CTABLE *ct1 = child->ct;
double epsilon =
(fabs(ct1->del.phi)+fabs(ct1->del.lam))/10000.0;
if( ct1->ll.phi - epsilon > input.phi
|| ct1->ll.lam - epsilon > input.lam
|| (ct1->ll.phi+(ct1->lim.phi-1)*ct1->del.phi + epsilon
< input.phi)
|| (ct1->ll.lam+(ct1->lim.lam-1)*ct1->del.lam + epsilon
< input.lam) )
continue;
break;
}
/* If we didn't find a child then nothing more to do */
if( child == NULL ) break;
/* Otherwise use the child, first checking it's children */
gi = child;
ct = child->ct;
}
/* load the grid shift info if we don't have it. */
if( ct->cvs == NULL && !pj_gridinfo_load( ctx, gi ) )
{
pj_ctx_set_errno( ctx, -38 );
return -38;
}
output = nad_cvt( input, inverse, ct );
if( output.lam != HUGE_VAL )
{
if( debug_count++ < 20 )
pj_log( ctx, PJ_LOG_DEBUG_MINOR,
"pj_apply_gridshift(): used %s", ct->id );
break;
}
}
if( output.lam == HUGE_VAL )
{
if( ctx->debug_level >= PJ_LOG_DEBUG_MAJOR )
{
pj_log( ctx, PJ_LOG_DEBUG_MAJOR,
"pj_apply_gridshift(): failed to find a grid shift table for\n"
" location (%.7fdW,%.7fdN)",
x[io] * RAD_TO_DEG,
y[io] * RAD_TO_DEG );
for( itable = 0; itable < grid_count; itable++ )
{
PJ_GRIDINFO *gi = tables[itable];
if( itable == 0 )
pj_log( ctx, PJ_LOG_DEBUG_MAJOR,
" tried: %s", gi->gridname );
else
pj_log( ctx, PJ_LOG_DEBUG_MAJOR,
",%s", gi->gridname );
}
}
/*
* We don't actually have any machinery currently to set the
* following macro, so this is mostly kept here to make it clear
* how we ought to operate if we wanted to make it super clear
* that an error has occured when points are outside our available
* datum shift areas. But if this is on, we will find that "low
* value" points on the fringes of some datasets will completely
* fail causing lots of problems when it is more or less ok to
* just not apply a datum shift. So rather than deal with
* that we just fallback to no shift. (see also bug #45).
*/
#ifdef ERR_GRID_AREA_TRANSIENT_SEVERE
y[io] = HUGE_VAL;
x[io] = HUGE_VAL;
#else
/* leave x/y unshifted. */
#endif
}
else
{
y[io] = output.phi;
x[io] = output.lam;
}
}
return 0;
}
proj-4.9.3/src/PJ_nzmg.c 0000644 0000000 0000000 00000012040 12761101536 011666 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Implementation of the nzmg (New Zealand Map Grid) projection.
* Very loosely based upon DMA code by Bradford W. Drew
* Author: Gerald Evenden
*
******************************************************************************
* Copyright (c) 1995, Gerald Evenden
*
* 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.
*****************************************************************************/
#define PJ_LIB__
#include
PROJ_HEAD(nzmg, "New Zealand Map Grid") "\n\tfixed Earth";
#define EPSLN 1e-10
#define SEC5_TO_RAD 0.4848136811095359935899141023
#define RAD_TO_SEC5 2.062648062470963551564733573
static COMPLEX bf[] = {
{ .7557853228, 0.0},
{ .249204646, 0.003371507},
{-.001541739, 0.041058560},
{-.10162907, 0.01727609},
{-.26623489, -0.36249218},
{-.6870983, -1.1651967} };
static double tphi[] = { 1.5627014243, .5185406398, -.03333098,
-.1052906, -.0368594, .007317,
.01220, .00394, -.0013 };
static double tpsi[] = { .6399175073, -.1358797613, .063294409, -.02526853, .0117879,
-.0055161, .0026906, -.001333, .00067, -.00034 };
#define Nbf 5
#define Ntpsi 9
#define Ntphi 8
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
COMPLEX p;
double *C;
int i;
lp.phi = (lp.phi - P->phi0) * RAD_TO_SEC5;
for (p.r = *(C = tpsi + (i = Ntpsi)); i ; --i)
p.r = *--C + lp.phi * p.r;
p.r *= lp.phi;
p.i = lp.lam;
p = pj_zpoly1(p, bf, Nbf);
xy.x = p.i;
xy.y = p.r;
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
int nn, i;
COMPLEX p, f, fp, dp;
double den, *C;
p.r = xy.y;
p.i = xy.x;
for (nn = 20; nn ;--nn) {
f = pj_zpolyd1(p, bf, Nbf, &fp);
f.r -= xy.y;
f.i -= xy.x;
den = fp.r * fp.r + fp.i * fp.i;
p.r += dp.r = -(f.r * fp.r + f.i * fp.i) / den;
p.i += dp.i = -(f.i * fp.r - f.r * fp.i) / den;
if ((fabs(dp.r) + fabs(dp.i)) <= EPSLN)
break;
}
if (nn) {
lp.lam = p.i;
for (lp.phi = *(C = tphi + (i = Ntphi)); i ; --i)
lp.phi = *--C + p.r * lp.phi;
lp.phi = P->phi0 + p.r * lp.phi * SEC5_TO_RAD;
} else
lp.lam = lp.phi = HUGE_VAL;
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(nzmg) {
/* force to International major axis */
P->ra = 1. / (P->a = 6378388.0);
P->lam0 = DEG_TO_RAD * 173.;
P->phi0 = DEG_TO_RAD * -41.;
P->x0 = 2510000.;
P->y0 = 6023150.;
P->inv = e_inverse;
P->fwd = e_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_nzmg_selftest (void) {return 0;}
#else
int pj_nzmg_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=nzmg +ellps=GRS80 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{3352675144.74742508, -7043205391.10024357},
{3691989502.77930641, -6729069415.33210468},
{4099000768.45323849, -7863208779.66724873},
{4466166927.36997604, -7502531736.62860489},
};
XY inv_in[] = {
{ 200000, 100000},
{ 200000,-100000},
{-200000, 100000},
{-200000,-100000}
};
LP e_inv_expect[] = {
{175.48208682711271, -69.4226921826331846},
{175.756819472543611, -69.5335710883796168},
{134.605119233460016, -61.4599957106629091},
{134.333684315954827, -61.6215536756024349},
};
return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
}
#endif
proj-4.9.3/src/PJ_nell_h.c 0000644 0000000 0000000 00000004362 12761101536 012164 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(nell_h, "Nell-Hammer") "\n\tPCyl., Sph.";
#define NITER 9
#define EPS 1e-7
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
(void) P;
xy.x = 0.5 * lp.lam * (1. + cos(lp.phi));
xy.y = 2.0 * (lp.phi - tan(0.5 *lp.phi));
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
double V, c, p;
int i;
(void) P;
p = 0.5 * xy.y;
for (i = NITER; i ; --i) {
c = cos(0.5 * lp.phi);
lp.phi -= V = (lp.phi - tan(lp.phi/2) - p)/(1. - 0.5/(c*c));
if (fabs(V) < EPS)
break;
}
if (!i) {
lp.phi = p < 0. ? -M_HALFPI : M_HALFPI;
lp.lam = 2. * xy.x;
} else
lp.lam = 2. * xy.x / (1. + cos(lp.phi));
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(nell_h) {
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_nell_h_selftest (void) {return 0;}
#else
int pj_nell_h_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=nell_h +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223385.131640952837, 111698.236533561678},
{ 223385.131640952837, -111698.236533561678},
{-223385.131640952837, 111698.236533561678},
{-223385.131640952837, -111698.236533561678},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00179049310989310567, 0.000895246554910125378},
{ 0.00179049310989310567, -0.000895246554910125378},
{-0.00179049310989310567, 0.000895246554910125378},
{-0.00179049310989310567, -0.000895246554910125378},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_wag3.c 0000644 0000000 0000000 00000004232 12761101536 011560 0000000 0000000 #define PJ_LIB__
# include
PROJ_HEAD(wag3, "Wagner III") "\n\tPCyl., Sph.\n\tlat_ts=";
#define TWOTHIRD 0.6666666666666666666667
struct pj_opaque {
double C_x;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
xy.x = P->opaque->C_x * lp.lam * cos(TWOTHIRD * lp.phi);
xy.y = lp.phi;
return xy;
}
#if 0
INVERSE(s_inverse); /* spheroid */
#endif
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
lp.phi = xy.y;
lp.lam = xy.x / (P->opaque->C_x * cos(TWOTHIRD * lp.phi));
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(wag3) {
double ts;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
ts = pj_param (P->ctx, P->params, "rlat_ts").f;
P->opaque->C_x = cos (ts) / cos (2.*ts/3.);
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_wag3_selftest (void) {return 0;}
#else
int pj_wag3_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=wag3 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{223387.02171816575, 111701.07212763709},
{223387.02171816575, -111701.07212763709},
{-223387.02171816575, 111701.07212763709},
{-223387.02171816575, -111701.07212763709},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{0.001790493109880963, 0.00089524655489191132},
{0.001790493109880963, -0.00089524655489191132},
{-0.001790493109880963, 0.00089524655489191132},
{-0.001790493109880963, -0.00089524655489191132},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/pj_factors.c 0000644 0000000 0000000 00000004761 12761101536 012467 0000000 0000000 /* projection scale factors */
#define PJ_LIB__
#include
#include
#ifndef DEFAULT_H
#define DEFAULT_H 1e-5 /* radian default for numeric h */
#endif
#define EPS 1.0e-12
int
pj_factors(LP lp, PJ *P, double h, struct FACTORS *fac) {
struct DERIVS der;
double cosphi, t, n, r;
/* check for forward and latitude or longitude overange */
if ((t = fabs(lp.phi)-M_HALFPI) > EPS || fabs(lp.lam) > 10.) {
pj_ctx_set_errno( P->ctx, -14);
return 1;
} else { /* proceed */
errno = pj_errno = 0;
P->ctx->last_errno = 0;
if (h < EPS)
h = DEFAULT_H;
if (fabs(lp.phi) > (M_HALFPI - h))
/* adjust to value around pi/2 where derived still exists*/
lp.phi = lp.phi < 0. ? (-M_HALFPI+h) : (M_HALFPI-h);
else if (P->geoc)
lp.phi = atan(P->rone_es * tan(lp.phi));
lp.lam -= P->lam0; /* compute del lp.lam */
if (!P->over)
lp.lam = adjlon(lp.lam); /* adjust del longitude */
if (P->spc) /* get what projection analytic values */
P->spc(lp, P, fac);
if (((fac->code & (IS_ANAL_XL_YL+IS_ANAL_XP_YP)) !=
(IS_ANAL_XL_YL+IS_ANAL_XP_YP)) &&
pj_deriv(lp, h, P, &der))
return 1;
if (!(fac->code & IS_ANAL_XL_YL)) {
fac->der.x_l = der.x_l;
fac->der.y_l = der.y_l;
}
if (!(fac->code & IS_ANAL_XP_YP)) {
fac->der.x_p = der.x_p;
fac->der.y_p = der.y_p;
}
cosphi = cos(lp.phi);
if (!(fac->code & IS_ANAL_HK)) {
fac->h = hypot(fac->der.x_p, fac->der.y_p);
fac->k = hypot(fac->der.x_l, fac->der.y_l) / cosphi;
if (P->es) {
t = sin(lp.phi);
t = 1. - P->es * t * t;
n = sqrt(t);
fac->h *= t * n / P->one_es;
fac->k *= n;
r = t * t / P->one_es;
} else
r = 1.;
} else if (P->es) {
r = sin(lp.phi);
r = 1. - P->es * r * r;
r = r * r / P->one_es;
} else
r = 1.;
/* convergence */
if (!(fac->code & IS_ANAL_CONV)) {
fac->conv = - atan2(fac->der.y_l, fac->der.x_l);
if (fac->code & IS_ANAL_XL_YL)
fac->code |= IS_ANAL_CONV;
}
/* areal scale factor */
fac->s = (fac->der.y_p * fac->der.x_l - fac->der.x_p * fac->der.y_l) *
r / cosphi;
/* meridian-parallel angle theta prime */
fac->thetap = aasin(P->ctx,fac->s / (fac->h * fac->k));
/* Tissot ellips axis */
t = fac->k * fac->k + fac->h * fac->h;
fac->a = sqrt(t + 2. * fac->s);
t = (t = t - 2. * fac->s) <= 0. ? 0. : sqrt(t);
fac->b = 0.5 * (fac->a - t);
fac->a = 0.5 * (fac->a + t);
/* omega */
fac->omega = 2. * aasin(P->ctx,(fac->a - fac->b)/(fac->a + fac->b));
}
return 0;
}
proj-4.9.3/src/PJ_loxim.c 0000644 0000000 0000000 00000005576 12761101536 012063 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(loxim, "Loximuthal") "\n\tPCyl Sph";
#define EPS 1e-8
struct pj_opaque {
double phi1;
double cosphi1;
double tanphi1;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
xy.y = lp.phi - Q->phi1;
if (fabs(xy.y) < EPS)
xy.x = lp.lam * Q->cosphi1;
else {
xy.x = M_FORTPI + 0.5 * lp.phi;
if (fabs(xy.x) < EPS || fabs(fabs(xy.x) - M_HALFPI) < EPS)
xy.x = 0.;
else
xy.x = lp.lam * xy.y / log( tan(xy.x) / Q->tanphi1 );
}
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
lp.phi = xy.y + Q->phi1;
if (fabs(xy.y) < EPS) {
lp.lam = xy.x / Q->cosphi1;
} else {
lp.lam = M_FORTPI + 0.5 * lp.phi;
if (fabs(lp.lam) < EPS || fabs(fabs(lp.lam) - M_HALFPI) < EPS)
lp.lam = 0.;
else
lp.lam = xy.x * log( tan(lp.lam) / Q->tanphi1 ) / xy.y ;
}
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(loxim) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
Q->cosphi1 = cos(Q->phi1);
if (Q->cosphi1 < EPS)
E_ERROR(-22);
Q->tanphi1 = tan(M_FORTPI + 0.5 * Q->phi1);
P->inv = s_inverse;
P->fwd = s_forward;
P->es = 0.;
return P;
}
#ifndef PJ_SELFTEST
int pj_loxim_selftest (void) {return 0;}
#else
int pj_loxim_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=loxim +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223382.295791338867, 55850.5360638185448},
{ 223393.637462243292, -167551.608191455656},
{-223382.295791338867, 55850.5360638185448},
{-223393.637462243292, -167551.608191455656},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00179056141104335601, 0.500895246554891926},
{ 0.00179056116683692576, 0.499104753445108074},
{-0.00179056141104335601, 0.500895246554891926},
{-0.00179056116683692576, 0.499104753445108074},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/emess.h 0000644 0000000 0000000 00000001163 12761101536 011447 0000000 0000000 /* Error message processing header file */
#ifndef EMESS_H
#define EMESS_H
struct EMESS {
char *File_name, /* input file name */
*Prog_name; /* name of program */
int File_line; /* approximate line read
where error occured */
};
#ifdef EMESS_ROUTINE /* use type */
/* for emess procedure */
struct EMESS emess_dat = { (char *)0, (char *)0, 0 };
#ifdef sun /* Archaic SunOs 4.1.1, etc. */
extern char *sys_errlist[];
#define strerror(n) (sys_errlist[n])
#endif
#else /* for for calling procedures */
extern struct EMESS emess_dat;
void emess(int, char *, ...);
#endif /* use type */
#endif /* end EMESS_H */
proj-4.9.3/src/PJ_eqdc.c 0000644 0000000 0000000 00000011602 12761101536 011632 0000000 0000000 #define PJ_LIB__
#include
struct pj_opaque {
double phi1;
double phi2;
double n;
double rho;
double rho0;
double c;
double *en;
int ellips;
};
PROJ_HEAD(eqdc, "Equidistant Conic")
"\n\tConic, Sph&Ell\n\tlat_1= lat_2=";
# define EPS10 1.e-10
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
Q->rho = Q->c - (Q->ellips ? pj_mlfn(lp.phi, sin(lp.phi),
cos(lp.phi), Q->en) : lp.phi);
xy.x = Q->rho * sin( lp.lam *= Q->n );
xy.y = Q->rho0 - Q->rho * cos(lp.lam);
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
if ((Q->rho = hypot(xy.x, xy.y = Q->rho0 - xy.y)) != 0.0 ) {
if (Q->n < 0.) {
Q->rho = -Q->rho;
xy.x = -xy.x;
xy.y = -xy.y;
}
lp.phi = Q->c - Q->rho;
if (Q->ellips)
lp.phi = pj_inv_mlfn(P->ctx, lp.phi, P->es, Q->en);
lp.lam = atan2(xy.x, xy.y) / Q->n;
} else {
lp.lam = 0.;
lp.phi = Q->n > 0. ? M_HALFPI : -M_HALFPI;
}
return lp;
}
static void special(LP lp, PJ *P, struct FACTORS *fac) {
struct pj_opaque *Q = P->opaque;
double sinphi, cosphi;
sinphi = sin(lp.phi);
cosphi = cos(lp.phi);
fac->code |= IS_ANAL_HK;
fac->h = 1.;
fac->k = Q->n * (Q->c - (Q->ellips ? pj_mlfn(lp.phi, sinphi,
cosphi, Q->en) : lp.phi)) / pj_msfn(sinphi, cosphi, P->es);
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
if (P->opaque->en)
pj_dealloc (P->opaque->en);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(eqdc) {
double cosphi, sinphi;
int secant;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
Q->phi2 = pj_param(P->ctx, P->params, "rlat_2").f;
if (fabs(Q->phi1 + Q->phi2) < EPS10) E_ERROR(-21);
if (!(Q->en = pj_enfn(P->es)))
E_ERROR_0;
Q->n = sinphi = sin(Q->phi1);
cosphi = cos(Q->phi1);
secant = fabs(Q->phi1 - Q->phi2) >= EPS10;
if( (Q->ellips = (P->es > 0.)) ) {
double ml1, m1;
m1 = pj_msfn(sinphi, cosphi, P->es);
ml1 = pj_mlfn(Q->phi1, sinphi, cosphi, Q->en);
if (secant) { /* secant cone */
sinphi = sin(Q->phi2);
cosphi = cos(Q->phi2);
Q->n = (m1 - pj_msfn(sinphi, cosphi, P->es)) /
(pj_mlfn(Q->phi2, sinphi, cosphi, Q->en) - ml1);
}
Q->c = ml1 + m1 / Q->n;
Q->rho0 = Q->c - pj_mlfn(P->phi0, sin(P->phi0),
cos(P->phi0), Q->en);
} else {
if (secant)
Q->n = (cosphi - cos(Q->phi2)) / (Q->phi2 - Q->phi1);
Q->c = Q->phi1 + cos(Q->phi1) / Q->n;
Q->rho0 = Q->c - P->phi0;
}
P->inv = e_inverse;
P->fwd = e_forward;
P->spc = special;
return P;
}
#ifndef PJ_SELFTEST
int pj_eqdc_selftest (void) {return 0;}
#else
int pj_eqdc_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=eqdc +ellps=GRS80 +lat_1=0.5 +lat_2=2"};
char s_args[] = {"+proj=eqdc +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222588.440269285755, 110659.134907347048},
{ 222756.836702042434, -110489.578087220681},
{-222588.440269285755, 110659.134907347048},
{-222756.836702042434, -110489.578087220681},
};
XY s_fwd_expect[] = {
{ 223351.088175113517, 111786.108747173785},
{ 223521.200266735133, -111615.970741240744},
{-223351.088175113517, 111786.108747173785},
{-223521.200266735133, -111615.970741240744},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.00179635944879094839, 0.000904368858588402644},
{ 0.00179635822020772734, -0.000904370095529954975},
{-0.00179635944879094839, 0.000904368858588402644},
{-0.00179635822020772734, -0.000904370095529954975},
};
LP s_inv_expect[] = {
{ 0.0017902210900486641, 0.000895245944814909169},
{ 0.00179021986984890255, -0.000895247165333684842},
{-0.0017902210900486641, 0.000895245944814909169},
{-0.00179021986984890255, -0.000895247165333684842},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
proj-4.9.3/src/proj.c 0000644 0000000 0000000 00000041244 12761101536 011304 0000000 0000000 /* <<<< Cartographic projection filter program >>>> */
#include "projects.h"
#include
#include
#include
#include
#include
#include "emess.h"
/* TK 1999-02-13 */
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__WIN32__)
# include
# include
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
#else
# define SET_BINARY_MODE(file)
#endif
/* ! TK 1999-02-13 */
#define MAX_LINE 1000
#define MAX_PARGS 100
#define PJ_INVERS(P) (P->inv ? 1 : 0)
static PJ
*Proj;
static projUV
(*proj)(projUV, PJ *);
static int
reversein = 0, /* != 0 reverse input arguments */
reverseout = 0, /* != 0 reverse output arguments */
bin_in = 0, /* != 0 then binary input */
bin_out = 0, /* != 0 then binary output */
echoin = 0, /* echo input data to output line */
tag = '#', /* beginning of line tag character */
inverse = 0, /* != 0 then inverse projection */
prescale = 0, /* != 0 apply cartesian scale factor */
dofactors = 0, /* determine scale factors */
facs_bad = 0, /* return condition from pj_factors */
very_verby = 0, /* very verbose mode */
postscale = 0;
static char
*cheby_str, /* string controlling Chebychev evaluation */
*oform = (char *)0, /* output format for x-y or decimal degrees */
*oterr = "*\t*", /* output line for unprojectable input */
*usage =
"%s\nusage: %s [ -bCeEfiIlormsStTvVwW [args] ] [ +opts[=arg] ] [ files ]\n";
static struct FACTORS
facs;
static double
(*informat)(const char *, char **), /* input data deformatter function */
fscale = 0.; /* cartesian scale factor */
static projUV
int_proj(projUV data) {
if (prescale) { data.u *= fscale; data.v *= fscale; }
data = (*proj)(data, Proj);
if (postscale && data.u != HUGE_VAL)
{ data.u *= fscale; data.v *= fscale; }
return(data);
}
static void /* file processing function */
process(FILE *fid) {
char line[MAX_LINE+3], *s, pline[40];
projUV data;
for (;;) {
++emess_dat.File_line;
if (bin_in) { /* binary input */
if (fread(&data, sizeof(projUV), 1, fid) != 1)
break;
} else { /* ascii input */
if (!(s = fgets(line, MAX_LINE, fid)))
break;
if (!strchr(s, '\n')) { /* overlong line */
int c;
(void)strcat(s, "\n");
/* gobble up to newline */
while ((c = fgetc(fid)) != EOF && c != '\n') ;
}
if (*s == tag) {
if (!bin_out)
(void)fputs(line, stdout);
continue;
}
if (reversein) {
data.v = (*informat)(s, &s);
data.u = (*informat)(s, &s);
} else {
data.u = (*informat)(s, &s);
data.v = (*informat)(s, &s);
}
if (data.v == HUGE_VAL)
data.u = HUGE_VAL;
if (!*s && (s > line)) --s; /* assumed we gobbled \n */
if (!bin_out && echoin) {
int t;
t = *s;
*s = '\0';
(void)fputs(line, stdout);
*s = t;
putchar('\t');
}
}
if (data.u != HUGE_VAL) {
if (prescale) { data.u *= fscale; data.v *= fscale; }
if (dofactors && !inverse)
facs_bad = pj_factors(data, Proj, 0., &facs);
data = (*proj)(data, Proj);
if (dofactors && inverse)
facs_bad = pj_factors(data, Proj, 0., &facs);
if (postscale && data.u != HUGE_VAL)
{ data.u *= fscale; data.v *= fscale; }
}
if (bin_out) { /* binary output */
(void)fwrite(&data, sizeof(projUV), 1, stdout);
continue;
} else if (data.u == HUGE_VAL) /* error output */
(void)fputs(oterr, stdout);
else if (inverse && !oform) { /*ascii DMS output */
if (reverseout) {
(void)fputs(rtodms(pline, data.v, 'N', 'S'), stdout);
putchar('\t');
(void)fputs(rtodms(pline, data.u, 'E', 'W'), stdout);
} else {
(void)fputs(rtodms(pline, data.u, 'E', 'W'), stdout);
putchar('\t');
(void)fputs(rtodms(pline, data.v, 'N', 'S'), stdout);
}
} else { /* x-y or decimal degree ascii output */
if (inverse) {
data.v *= RAD_TO_DEG;
data.u *= RAD_TO_DEG;
}
if (reverseout) {
(void)printf(oform,data.v); putchar('\t');
(void)printf(oform,data.u);
} else {
(void)printf(oform,data.u); putchar('\t');
(void)printf(oform,data.v);
}
}
if (dofactors) /* print scale factor data */
{
if (!facs_bad)
(void)printf("\t<%g %g %g %g %g %g>",
facs.h, facs.k, facs.s,
facs.omega * RAD_TO_DEG, facs.a, facs.b);
else
(void)fputs("\t<* * * * * *>", stdout);
}
(void)fputs(bin_in ? "\n" : s, stdout);
}
}
static void /* file processing function --- verbosely */
vprocess(FILE *fid) {
char line[MAX_LINE+3], *s, pline[40];
projUV dat_ll, dat_xy;
int linvers;
if (!oform)
oform = "%.3f";
if (bin_in || bin_out)
emess(1,"binary I/O not available in -V option");
for (;;) {
++emess_dat.File_line;
if (!(s = fgets(line, MAX_LINE, fid)))
break;
if (!strchr(s, '\n')) { /* overlong line */
int c;
(void)strcat(s, "\n");
/* gobble up to newline */
while ((c = fgetc(fid)) != EOF && c != '\n') ;
}
if (*s == tag) { /* pass on data */
(void)fputs(s, stdout);
continue;
}
/* check to override default input mode */
if (*s == 'I' || *s == 'i') {
linvers = 1;
++s;
} else if (*s == 'I' || *s == 'i') {
linvers = 0;
++s;
} else
linvers = inverse;
if (linvers) {
if (!PJ_INVERS(Proj)) {
emess(-1,"inverse for this projection not avail.\n");
continue;
}
dat_xy.u = strtod(s, &s);
dat_xy.v = strtod(s, &s);
if (dat_xy.u == HUGE_VAL || dat_xy.v == HUGE_VAL) {
emess(-1,"lon-lat input conversion failure\n");
continue;
}
if (prescale) { dat_xy.u *= fscale; dat_xy.v *= fscale; }
dat_ll = pj_inv(dat_xy, Proj);
} else {
dat_ll.u = dmstor(s, &s);
dat_ll.v = dmstor(s, &s);
if (dat_ll.u == HUGE_VAL || dat_ll.v == HUGE_VAL) {
emess(-1,"lon-lat input conversion failure\n");
continue;
}
dat_xy = pj_fwd(dat_ll, Proj);
if (postscale) { dat_xy.u *= fscale; dat_xy.v *= fscale; }
}
if (pj_errno) {
emess(-1, pj_strerrno(pj_errno));
continue;
}
if (!*s && (s > line)) --s; /* assumed we gobbled \n */
if (pj_factors(dat_ll, Proj, 0., &facs)) {
emess(-1,"failed to conpute factors\n\n");
continue;
}
if (*s != '\n')
(void)fputs(s, stdout);
(void)fputs("Longitude: ", stdout);
(void)fputs(rtodms(pline, dat_ll.u, 'E', 'W'), stdout);
(void)printf(" [ %.11g ]\n", dat_ll.u * RAD_TO_DEG);
(void)fputs("Latitude: ", stdout);
(void)fputs(rtodms(pline, dat_ll.v, 'N', 'S'), stdout);
(void)printf(" [ %.11g ]\n", dat_ll.v * RAD_TO_DEG);
(void)fputs("Easting (x): ", stdout);
(void)printf(oform, dat_xy.u); putchar('\n');
(void)fputs("Northing (y): ", stdout);
(void)printf(oform, dat_xy.v); putchar('\n');
(void)printf("Meridian scale (h)%c: %.8f ( %.4g %% error )\n",
facs.code & IS_ANAL_HK ? '*' : ' ', facs.h, (facs.h-1.)*100.);
(void)printf("Parallel scale (k)%c: %.8f ( %.4g %% error )\n",
facs.code & IS_ANAL_HK ? '*' : ' ', facs.k, (facs.k-1.)*100.);
(void)printf("Areal scale (s): %.8f ( %.4g %% error )\n",
facs.s, (facs.s-1.)*100.);
(void)printf("Angular distortion (w): %.3f\n", facs.omega *
RAD_TO_DEG);
(void)printf("Meridian/Parallel angle: %.5f\n",
facs.thetap * RAD_TO_DEG);
(void)printf("Convergence%c: ",facs.code & IS_ANAL_CONV ? '*' : ' ');
(void)fputs(rtodms(pline, facs.conv, 0, 0), stdout);
(void)printf(" [ %.8f ]\n", facs.conv * RAD_TO_DEG);
(void)printf("Max-min (Tissot axis a-b) scale error: %.5f %.5f\n\n",
facs.a, facs.b);
}
}
int main(int argc, char **argv) {
char *arg, **eargv = argv, *pargv[MAX_PARGS], **iargv = argv;
FILE *fid;
int pargc = 0, iargc = argc, eargc = 0, c, mon = 0;
if ( (emess_dat.Prog_name = strrchr(*argv,DIR_CHAR)) != NULL)
++emess_dat.Prog_name;
else emess_dat.Prog_name = *argv;
inverse = ! strncmp(emess_dat.Prog_name, "inv", 3);
if (argc <= 1 ) {
(void)fprintf(stderr, usage, pj_get_release(), emess_dat.Prog_name);
exit (0);
}
/* process run line arguments */
while (--argc > 0) { /* collect run line arguments */
if(**++argv == '-') for(arg = *argv;;) {
switch(*++arg) {
case '\0': /* position of "stdin" */
if (arg[-1] == '-') eargv[eargc++] = "-";
break;
case 'b': /* binary I/O */
bin_in = bin_out = 1;
continue;
case 'C': /* Check - run internal regression tests */
return pj_run_selftests (very_verby);
continue;
case 'v': /* monitor dump of initialization */
mon = 1;
continue;
case 'i': /* input binary */
bin_in = 1;
continue;
case 'o': /* output binary */
bin_out = 1;
continue;
case 'I': /* alt. method to spec inverse */
inverse = 1;
continue;
case 'E': /* echo ascii input to ascii output */
echoin = 1;
continue;
case 'V': /* very verbose processing mode */
very_verby = 1;
mon = 1;
case 'S': /* compute scale factors */
dofactors = 1;
continue;
case 't': /* set col. one char */
if (arg[1]) tag = *++arg;
else emess(1,"missing -t col. 1 tag");
continue;
case 'l': /* list projections, ellipses or units */
if (!arg[1] || arg[1] == 'p' || arg[1] == 'P') {
/* list projections */
struct PJ_LIST *lp;
int do_long = arg[1] == 'P', c;
char *str;
for (lp = pj_get_list_ref() ; lp->id ; ++lp) {
if( strcmp(lp->id,"latlong") == 0
|| strcmp(lp->id,"longlat") == 0
|| strcmp(lp->id,"geocent") == 0 )
continue;
(void)printf("%s : ", lp->id);
if (do_long) /* possibly multiline description */
(void)puts(*lp->descr);
else { /* first line, only */
str = *lp->descr;
while ((c = *str++) && c != '\n')
putchar(c);
putchar('\n');
}
}
} else if (arg[1] == '=') { /* list projection 'descr' */
struct PJ_LIST *lp;
arg += 2;
for (lp = pj_get_list_ref(); lp->id ; ++lp)
if (!strcmp(lp->id, arg)) {
(void)printf("%9s : %s\n", lp->id, *lp->descr);
break;
}
} else if (arg[1] == 'e') { /* list ellipses */
struct PJ_ELLPS *le;
for (le = pj_get_ellps_ref(); le->id ; ++le)
(void)printf("%9s %-16s %-16s %s\n",
le->id, le->major, le->ell, le->name);
} else if (arg[1] == 'u') { /* list units */
struct PJ_UNITS *lu;
for (lu = pj_get_units_ref(); lu->id ; ++lu)
(void)printf("%12s %-20s %s\n",
lu->id, lu->to_meter, lu->name);
} else if (arg[1] == 'd') { /* list datums */
struct PJ_DATUMS *ld;
printf("__datum_id__ __ellipse___ __definition/comments______________________________\n" );
for (ld = pj_get_datums_ref(); ld->id ; ++ld)
{
printf("%12s %-12s %-30s\n",
ld->id, ld->ellipse_id, ld->defn);
if( ld->comments != NULL && strlen(ld->comments) > 0 )
printf( "%25s %s\n", " ", ld->comments );
}
} else
emess(1,"invalid list option: l%c",arg[1]);
exit(0);
continue; /* artificial */
case 'e': /* error line alternative */
if (--argc <= 0)
noargument:
emess(1,"missing argument for -%c",*arg);
oterr = *++argv;
continue;
case 'T': /* generate Chebyshev coefficients */
if (--argc <= 0) goto noargument;
cheby_str = *++argv;
continue;
case 'm': /* cartesian multiplier */
if (--argc <= 0) goto noargument;
postscale = 1;
if (!strncmp("1/",*++argv,2) ||
!strncmp("1:",*argv,2)) {
if((fscale = atof((*argv)+2)) == 0.)
goto badscale;
fscale = 1. / fscale;
} else
if ((fscale = atof(*argv)) == 0.) {
badscale:
emess(1,"invalid scale argument");
}
continue;
case 'W': /* specify seconds precision */
case 'w': /* -W for constant field width */
if ((c = arg[1]) != 0 && isdigit(c)) {
set_rtodms(c - '0', *arg == 'W');
++arg;
} else
emess(1,"-W argument missing or non-digit");
continue;
case 'f': /* alternate output format degrees or xy */
if (--argc <= 0) goto noargument;
oform = *++argv;
continue;
case 'r': /* reverse input */
reversein = 1;
continue;
case 's': /* reverse output */
reverseout = 1;
continue;
default:
emess(1, "invalid option: -%c",*arg);
break;
}
break;
} else if (**argv == '+') { /* + argument */
if (pargc < MAX_PARGS)
pargv[pargc++] = *argv + 1;
else
emess(1,"overflowed + argument table");
} else /* assumed to be input file name(s) */
eargv[eargc++] = *argv;
}
if (eargc == 0 && !cheby_str) /* if no specific files force sysin */
eargv[eargc++] = "-";
else if (eargc > 0 && cheby_str) /* warning */
emess(4, "data files when generating Chebychev prohibited");
/* done with parameter and control input */
if (inverse && postscale) {
prescale = 1;
postscale = 0;
fscale = 1./fscale;
}
if (!(Proj = pj_init(pargc, pargv)))
emess(3,"projection initialization failure\ncause: %s",
pj_strerrno(pj_errno));
if( pj_is_latlong( Proj ) )
{
emess( 3, "+proj=latlong unsuitable for use with proj program." );
exit( 0 );
}
if (inverse) {
if (!Proj->inv)
emess(3,"inverse projection not available");
proj = pj_inv;
} else
proj = pj_fwd;
if (cheby_str) {
extern void gen_cheb(int, projUV(*)(projUV), char *, PJ *, int, char **);
gen_cheb(inverse, int_proj, cheby_str, Proj, iargc, iargv);
exit(0);
}
/* set input formating control */
if (mon) {
pj_pr_list(Proj);
if (very_verby) {
(void)printf("#Final Earth figure: ");
if (Proj->es) {
(void)printf("ellipsoid\n# Major axis (a): ");
(void)printf(oform ? oform : "%.3f", Proj->a);
(void)printf("\n# 1/flattening: %.6f\n",
1./(1. - sqrt(1. - Proj->es)));
(void)printf("# squared eccentricity: %.12f\n", Proj->es);
} else {
(void)printf("sphere\n# Radius: ");
(void)printf(oform ? oform : "%.3f", Proj->a);
(void)putchar('\n');
}
}
}
if (inverse)
informat = strtod;
else {
informat = dmstor;
if (!oform)
oform = "%.2f";
}
if (bin_out)
{
SET_BINARY_MODE(stdout);
}
/* process input file list */
for ( ; eargc-- ; ++eargv) {
if (**eargv == '-') {
fid = stdin;
emess_dat.File_name = "";
if (bin_in)
{
SET_BINARY_MODE(stdin);
}
} else {
if ((fid = fopen(*eargv, "rb")) == NULL) {
emess(-2, *eargv, "input file");
continue;
}
emess_dat.File_name = *eargv;
}
emess_dat.File_line = 0;
if (very_verby)
vprocess(fid);
else
process(fid);
(void)fclose(fid);
emess_dat.File_name = 0;
}
if( Proj )
pj_free(Proj);
exit(0); /* normal completion */
}
proj-4.9.3/src/PJ_mbt_fps.c 0000644 0000000 0000000 00000004760 12761101536 012357 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(mbt_fps, "McBryde-Thomas Flat-Pole Sine (No. 2)") "\n\tCyl., Sph.";
#define MAX_ITER 10
#define LOOP_TOL 1e-7
#define C1 0.45503
#define C2 1.36509
#define C3 1.41546
#define C_x 0.22248
#define C_y 1.44492
#define C1_2 0.33333333333333333333333333
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
double k, V, t;
int i;
(void) P;
k = C3 * sin(lp.phi);
for (i = MAX_ITER; i ; --i) {
t = lp.phi / C2;
lp.phi -= V = (C1 * sin(t) + sin(lp.phi) - k) /
(C1_2 * cos(t) + cos(lp.phi));
if (fabs(V) < LOOP_TOL)
break;
}
t = lp.phi / C2;
xy.x = C_x * lp.lam * (1. + 3. * cos(lp.phi)/cos(t) );
xy.y = C_y * sin(t);
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
double t;
lp.phi = C2 * (t = aasin(P->ctx,xy.y / C_y));
lp.lam = xy.x / (C_x * (1. + 3. * cos(lp.phi)/cos(t)));
lp.phi = aasin(P->ctx,(C1 * sin(t) + sin(lp.phi)) / C3);
return (lp);
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(mbt_fps) {
P->es = 0;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_mbt_fps_selftest (void) {return 0;}
#else
int pj_mbt_fps_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=mbt_fps +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 198798.176129849948, 125512.017254530627},
{ 198798.176129849948, -125512.017254530627},
{-198798.176129849948, 125512.017254530627},
{-198798.176129849948, -125512.017254530627},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00201197086238270742, 0.000796711850174446003},
{ 0.00201197086238270742, -0.000796711850174446003},
{-0.00201197086238270742, 0.000796711850174446003},
{-0.00201197086238270742, -0.000796711850174446003},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_eck4.c 0000644 0000000 0000000 00000005176 12761101536 011555 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(eck4, "Eckert IV") "\n\tPCyl, Sph.";
#define C_x .42223820031577120149
#define C_y 1.32650042817700232218
#define RC_y .75386330736002178205
#define C_p 3.57079632679489661922
#define RC_p .28004957675577868795
#define EPS 1e-7
#define NITER 6
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
double p, V, s, c;
int i;
(void) P;
p = C_p * sin(lp.phi);
V = lp.phi * lp.phi;
lp.phi *= 0.895168 + V * ( 0.0218849 + V * 0.00826809 );
for (i = NITER; i ; --i) {
c = cos(lp.phi);
s = sin(lp.phi);
lp.phi -= V = (lp.phi + s * (c + 2.) - p) /
(1. + c * (c + 2.) - s * s);
if (fabs(V) < EPS)
break;
}
if (!i) {
xy.x = C_x * lp.lam;
xy.y = lp.phi < 0. ? -C_y : C_y;
} else {
xy.x = C_x * lp.lam * (1. + cos(lp.phi));
xy.y = C_y * sin(lp.phi);
}
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
double c;
lp.phi = aasin(P->ctx,xy.y / C_y);
lp.lam = xy.x / (C_x * (1. + (c = cos(lp.phi))));
lp.phi = aasin(P->ctx,(lp.phi + sin(lp.phi) * (c + 2.)) / C_p);
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(eck4) {
P->es = 0.0;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_eck4_selftest (void) {return 0;}
#else
int pj_eck4_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=eck4 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 188646.38935641639, 132268.54017406539},
{ 188646.38935641639, -132268.54017406539},
{-188646.38935641639, 132268.54017406539},
{-188646.38935641639, -132268.54017406539},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0021202405520236059, 0.00075601458836610643},
{ 0.0021202405520236059, -0.00075601458836610643},
{-0.0021202405520236059, 0.00075601458836610643},
{-0.0021202405520236059, -0.00075601458836610643},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/cs2cs.c 0000644 0000000 0000000 00000036265 12761101536 011356 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Mainline program sort of like ``proj'' for converting between
* two coordinate systems.
* Author: Frank Warmerdam, warmerda@home.com
*
******************************************************************************
* 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.
*****************************************************************************/
#include "projects.h"
#include
#include
#include
#include
#include
#include "emess.h"
#include
#define MAX_LINE 1000
#define MAX_PARGS 100
static projPJ fromProj, toProj;
static int
reversein = 0, /* != 0 reverse input arguments */
reverseout = 0, /* != 0 reverse output arguments */
echoin = 0, /* echo input data to output line */
tag = '#'; /* beginning of line tag character */
static char
*oform = (char *)0, /* output format for x-y or decimal degrees */
*oterr = "*\t*", /* output line for unprojectable input */
*usage =
"%s\nusage: %s [ -eEfIlrstvwW [args] ] [ +opts[=arg] ]\n"
" [+to [+opts[=arg] [ files ]\n";
static double (*informat)(const char *,
char **); /* input data deformatter function */
/************************************************************************/
/* process() */
/* */
/* File processing function. */
/************************************************************************/
static void process(FILE *fid)
{
char line[MAX_LINE+3], *s, pline[40];
projUV data;
for (;;) {
double z;
++emess_dat.File_line;
if (!(s = fgets(line, MAX_LINE, fid)))
break;
if (!strchr(s, '\n')) { /* overlong line */
int c;
(void)strcat(s, "\n");
/* gobble up to newline */
while ((c = fgetc(fid)) != EOF && c != '\n') ;
}
if (*s == tag) {
fputs(line, stdout);
continue;
}
if (reversein) {
data.v = (*informat)(s, &s);
data.u = (*informat)(s, &s);
} else {
data.u = (*informat)(s, &s);
data.v = (*informat)(s, &s);
}
z = strtod( s, &s );
if (data.v == HUGE_VAL)
data.u = HUGE_VAL;
if (!*s && (s > line)) --s; /* assumed we gobbled \n */
if ( echoin) {
int t;
t = *s;
*s = '\0';
(void)fputs(line, stdout);
*s = t;
putchar('\t');
}
if (data.u != HUGE_VAL) {
if( pj_transform( fromProj, toProj, 1, 0,
&(data.u), &(data.v), &z ) != 0 )
{
data.u = HUGE_VAL;
data.v = HUGE_VAL;
emess(-3,"pj_transform(): %s", pj_strerrno(pj_errno));
}
}
if (data.u == HUGE_VAL) /* error output */
fputs(oterr, stdout);
else if (pj_is_latlong(toProj) && !oform) { /*ascii DMS output */
if (reverseout) {
fputs(rtodms(pline, data.v, 'N', 'S'), stdout);
putchar('\t');
fputs(rtodms(pline, data.u, 'E', 'W'), stdout);
} else {
fputs(rtodms(pline, data.u, 'E', 'W'), stdout);
putchar('\t');
fputs(rtodms(pline, data.v, 'N', 'S'), stdout);
}
} else { /* x-y or decimal degree ascii output */
if ( pj_is_latlong(toProj) ) {
data.v *= RAD_TO_DEG;
data.u *= RAD_TO_DEG;
}
if (reverseout) {
printf(oform,data.v); putchar('\t');
printf(oform,data.u);
} else {
printf(oform,data.u); putchar('\t');
printf(oform,data.v);
}
}
putchar(' ');
if( oform != NULL )
printf( oform, z );
else
printf( "%.3f", z );
if( s )
printf( "%s", s );
else
printf( "\n" );
}
}
/************************************************************************/
/* main() */
/************************************************************************/
int main(int argc, char **argv)
{
char *arg, **eargv = argv, *from_argv[MAX_PARGS], *to_argv[MAX_PARGS];
FILE *fid;
int from_argc=0, to_argc=0, eargc = 0, c, mon = 0;
int have_to_flag = 0, inverse = 0, i;
int use_env_locale = 0;
/* This is just to check that pj_init() is locale-safe */
/* Used by nad/testvarious */
if( getenv("PROJ_USE_ENV_LOCALE") != NULL )
use_env_locale = 1;
if ((emess_dat.Prog_name = strrchr(*argv,DIR_CHAR)) != NULL)
++emess_dat.Prog_name;
else emess_dat.Prog_name = *argv;
inverse = ! strncmp(emess_dat.Prog_name, "inv", 3);
if (argc <= 1 ) {
(void)fprintf(stderr, usage, pj_get_release(), emess_dat.Prog_name);
exit (0);
}
/* process run line arguments */
while (--argc > 0) { /* collect run line arguments */
if(**++argv == '-') for(arg = *argv;;) {
switch(*++arg) {
case '\0': /* position of "stdin" */
if (arg[-1] == '-') eargv[eargc++] = "-";
break;
case 'v': /* monitor dump of initialization */
mon = 1;
continue;
case 'I': /* alt. method to spec inverse */
inverse = 1;
continue;
case 'E': /* echo ascii input to ascii output */
echoin = 1;
continue;
case 't': /* set col. one char */
if (arg[1]) tag = *++arg;
else emess(1,"missing -t col. 1 tag");
continue;
case 'l': /* list projections, ellipses or units */
if (!arg[1] || arg[1] == 'p' || arg[1] == 'P') {
/* list projections */
struct PJ_LIST *lp;
int do_long = arg[1] == 'P', c;
char *str;
for (lp = pj_get_list_ref() ; lp->id ; ++lp) {
(void)printf("%s : ", lp->id);
if (do_long) /* possibly multiline description */
(void)puts(*lp->descr);
else { /* first line, only */
str = *lp->descr;
while ((c = *str++) && c != '\n')
putchar(c);
putchar('\n');
}
}
} else if (arg[1] == '=') { /* list projection 'descr' */
struct PJ_LIST *lp;
arg += 2;
for (lp = pj_get_list_ref() ; lp->id ; ++lp)
if (!strcmp(lp->id, arg)) {
(void)printf("%9s : %s\n", lp->id, *lp->descr);
break;
}
} else if (arg[1] == 'e') { /* list ellipses */
struct PJ_ELLPS *le;
for (le = pj_get_ellps_ref(); le->id ; ++le)
(void)printf("%9s %-16s %-16s %s\n",
le->id, le->major, le->ell, le->name);
} else if (arg[1] == 'u') { /* list units */
struct PJ_UNITS *lu;
for (lu = pj_get_units_ref(); lu->id ; ++lu)
(void)printf("%12s %-20s %s\n",
lu->id, lu->to_meter, lu->name);
} else if (arg[1] == 'd') { /* list datums */
struct PJ_DATUMS *ld;
printf("__datum_id__ __ellipse___ __definition/comments______________________________\n" );
for (ld = pj_get_datums_ref(); ld->id ; ++ld)
{
printf("%12s %-12s %-30s\n",
ld->id, ld->ellipse_id, ld->defn);
if( ld->comments != NULL && strlen(ld->comments) > 0 )
printf( "%25s %s\n", " ", ld->comments );
}
} else if( arg[1] == 'm') { /* list prime meridians */
struct PJ_PRIME_MERIDIANS *lpm;
for (lpm = pj_get_prime_meridians_ref(); lpm->id ; ++lpm)
(void)printf("%12s %-30s\n",
lpm->id, lpm->defn);
} else
emess(1,"invalid list option: l%c",arg[1]);
exit(0);
continue; /* artificial */
case 'e': /* error line alternative */
if (--argc <= 0)
noargument:
emess(1,"missing argument for -%c",*arg);
oterr = *++argv;
continue;
case 'W': /* specify seconds precision */
case 'w': /* -W for constant field width */
if ((c = arg[1]) != 0 && isdigit(c)) {
set_rtodms(c - '0', *arg == 'W');
++arg;
} else
emess(1,"-W argument missing or non-digit");
continue;
case 'f': /* alternate output format degrees or xy */
if (--argc <= 0) goto noargument;
oform = *++argv;
continue;
case 'r': /* reverse input */
reversein = 1;
continue;
case 's': /* reverse output */
reverseout = 1;
continue;
case 'd': /* set debug level */
if (--argc <= 0) goto noargument;
pj_ctx_set_debug( pj_get_default_ctx(), atoi(*++argv));
continue;
default:
emess(1, "invalid option: -%c",*arg);
break;
}
break;
} else if (strcmp(*argv,"+to") == 0 ) {
have_to_flag = 1;
} else if (**argv == '+') { /* + argument */
if( have_to_flag )
{
if( to_argc < MAX_PARGS )
to_argv[to_argc++] = *argv + 1;
else
emess(1,"overflowed + argument table");
}
else
{
if (from_argc < MAX_PARGS)
from_argv[from_argc++] = *argv + 1;
else
emess(1,"overflowed + argument table");
}
} else /* assumed to be input file name(s) */
eargv[eargc++] = *argv;
}
if (eargc == 0 ) /* if no specific files force sysin */
eargv[eargc++] = "-";
/*
* If the user has requested inverse, then just reverse the
* coordinate systems.
*/
if( inverse )
{
int argcount;
for( i = 0; i < MAX_PARGS; i++ )
{
char *arg;
arg = from_argv[i];
from_argv[i] = to_argv[i];
to_argv[i] = arg;
}
argcount = from_argc;
from_argc = to_argc;
to_argc = argcount;
}
if( use_env_locale )
{
/* Set locale from environment */
setlocale(LC_ALL, "");
}
if( from_argc == 0 && to_argc != 0 )
{
/* we will generate the from proj as the latlong of the +to in a bit */
}
else if (!(fromProj = pj_init(from_argc, from_argv)))
{
printf( "Using from definition: " );
for( i = 0; i < from_argc; i++ )
printf( "%s ", from_argv[i] );
printf( "\n" );
emess(3,"projection initialization failure\ncause: %s",
pj_strerrno(pj_errno));
}
if( to_argc == 0 )
{
if (!(toProj = pj_latlong_from_proj( fromProj )))
{
printf( "Using to definition: " );
for( i = 0; i < to_argc; i++ )
printf( "%s ", to_argv[i] );
printf( "\n" );
emess(3,"projection initialization failure\ncause: %s",
pj_strerrno(pj_errno));
}
}
else if (!(toProj = pj_init(to_argc, to_argv)))
{
printf( "Using to definition: " );
for( i = 0; i < to_argc; i++ )
printf( "%s ", to_argv[i] );
printf( "\n" );
emess(3,"projection initialization failure\ncause: %s",
pj_strerrno(pj_errno));
}
if( from_argc == 0 && toProj != NULL)
{
if (!(fromProj = pj_latlong_from_proj( toProj )))
{
printf( "Using to definition: " );
for( i = 0; i < to_argc; i++ )
printf( "%s ", to_argv[i] );
printf( "\n" );
emess(3,"projection initialization failure\ncause: %s",
pj_strerrno(pj_errno));
}
}
if( use_env_locale )
{
/* Restore C locale to avoid issues in parsing/outputing numbers*/
setlocale(LC_ALL, "C");
}
if (mon) {
printf( "%c ---- From Coordinate System ----\n", tag );
pj_pr_list(fromProj);
printf( "%c ---- To Coordinate System ----\n", tag );
pj_pr_list(toProj);
}
/* set input formating control */
if( !fromProj->is_latlong )
informat = strtod;
else {
informat = dmstor;
}
if( !toProj->is_latlong && !oform )
oform = "%.2f";
/* process input file list */
for ( ; eargc-- ; ++eargv) {
if (**eargv == '-') {
fid = stdin;
emess_dat.File_name = "";
} else {
if ((fid = fopen(*eargv, "rt")) == NULL) {
emess(-2, *eargv, "input file");
continue;
}
emess_dat.File_name = *eargv;
}
emess_dat.File_line = 0;
process(fid);
fclose(fid);
emess_dat.File_name = 0;
}
if( fromProj != NULL )
pj_free( fromProj );
if( toProj != NULL )
pj_free( toProj );
pj_deallocate_grids();
exit(0); /* normal completion */
}
proj-4.9.3/src/pj_strtod.c 0000644 0000000 0000000 00000015067 12761101536 012346 0000000 0000000 /******************************************************************************
*
* Derived from GDAL port/cpl_strtod.cpp
* Purpose: Functions to convert ASCII string to floating point number.
* Author: Andrey Kiselev, dron@ak4719.spb.edu.
*
******************************************************************************
* Copyright (c) 2006, Andrey Kiselev
* Copyright (c) 2008-2012, Even Rouault
*
* 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.
****************************************************************************/
#include "projects.h"
/* Windows nmake build doesn't have a proj_config.h, but HAVE_LOCALECONV */
/* is defined in the compilation line */
#ifndef HAVE_LOCALECONV
#include "proj_config.h"
#endif
#include
#include
#include
#define PJ_STRTOD_WORK_BUFFER_SIZE 64
/************************************************************************/
/* pj_atof() */
/************************************************************************/
/**
* Converts ASCII string to floating point number.
*
* This function converts the initial portion of the string pointed to
* by nptr to double floating point representation. The behaviour is the
* same as
*
* pj_strtod(nptr, (char **)NULL);
*
* This function does the same as standard atof(3), but does not take
* locale in account. That means, the decimal delimiter is always '.'
* (decimal point).
*
* @param nptr Pointer to string to convert.
*
* @return Converted value.
*/
double pj_atof( const char* nptr )
{
return pj_strtod(nptr, NULL);
}
/************************************************************************/
/* pj_replace_point_by_locale_point() */
/************************************************************************/
static char* pj_replace_point_by_locale_point(const char* pszNumber, char point,
char* pszWorkBuffer)
{
#if !defined(HAVE_LOCALECONV) || defined(_WIN32_WCE)
#if defined(_MSC_VER) /* Visual C++ */
#pragma message("localeconv not available")
#else
#warning "localeconv not available"
#endif
static char byPoint = 0;
if (byPoint == 0)
{
char szBuf[16];
sprintf(szBuf, "%.1f", 1.0);
byPoint = szBuf[1];
}
if (point != byPoint)
{
const char* pszPoint = strchr(pszNumber, point);
if (pszPoint)
{
char* pszNew;
if( strlen(pszNumber) < PJ_STRTOD_WORK_BUFFER_SIZE )
{
strcpy(pszWorkBuffer, pszNumber);
pszNew = pszWorkBuffer;
}
else
pszNew = strdup(pszNumber);
pszNew[pszPoint - pszNumber] = byPoint;
return pszNew;
}
}
#else
struct lconv *poLconv = localeconv();
if ( poLconv
&& poLconv->decimal_point
&& poLconv->decimal_point[0] != '\0' )
{
char byPoint = poLconv->decimal_point[0];
if (point != byPoint)
{
const char* pszLocalePoint = strchr(pszNumber, byPoint);
const char* pszPoint = strchr(pszNumber, point);
if (pszPoint || pszLocalePoint)
{
char* pszNew;
if( strlen(pszNumber) < PJ_STRTOD_WORK_BUFFER_SIZE )
{
strcpy(pszWorkBuffer, pszNumber);
pszNew = pszWorkBuffer;
}
else
pszNew = strdup(pszNumber);
if( pszLocalePoint )
pszNew[pszLocalePoint - pszNumber] = ' ';
if( pszPoint )
pszNew[pszPoint - pszNumber] = byPoint;
return pszNew;
}
}
}
#endif
return (char*) pszNumber;
}
/************************************************************************/
/* pj_strtod() */
/************************************************************************/
/**
* Converts ASCII string to floating point number.
*
* This function converts the initial portion of the string pointed to
* by nptr to double floating point representation. This function does the
* same as standard strtod(3), but does not take locale in account and use
* decimal point.
*
* @param nptr Pointer to string to convert.
* @param endptr If is not NULL, a pointer to the character after the last
* character used in the conversion is stored in the location referenced
* by endptr.
* @param point Decimal delimiter.
*
* @return Converted value.
*/
double pj_strtod( const char *nptr, char **endptr )
{
/* -------------------------------------------------------------------- */
/* We are implementing a simple method here: copy the input string */
/* into the temporary buffer, replace the specified decimal delimiter */
/* with the one, taken from locale settings and use standard strtod() */
/* on that buffer. */
/* -------------------------------------------------------------------- */
double dfValue;
int nError;
char szWorkBuffer[PJ_STRTOD_WORK_BUFFER_SIZE];
char* pszNumber = pj_replace_point_by_locale_point(nptr, '.', szWorkBuffer);
dfValue = strtod( pszNumber, endptr );
nError = errno;
if ( endptr )
*endptr = (char *)nptr + (*endptr - pszNumber);
if (pszNumber != (char*) nptr && pszNumber != szWorkBuffer )
free( pszNumber );
errno = nError;
return dfValue;
}
proj-4.9.3/src/PJ_eck3.c 0000644 0000000 0000000 00000015244 12761101536 011551 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(eck3, "Eckert III") "\n\tPCyl, Sph.";
PROJ_HEAD(putp1, "Putnins P1") "\n\tPCyl, Sph.";
PROJ_HEAD(wag6, "Wagner VI") "\n\tPCyl, Sph.";
PROJ_HEAD(kav7, "Kavraisky VII") "\n\tPCyl, Sph.";
struct pj_opaque {
double C_x, C_y, A, B;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
xy.y = Q->C_y * lp.phi;
xy.x = Q->C_x * lp.lam * (Q->A + asqrt(1. - Q->B * lp.phi * lp.phi));
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
lp.phi = xy.y / Q->C_y;
lp.lam = xy.x / (Q->C_x * (Q->A + asqrt(1. - Q->B * lp.phi * lp.phi)));
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
static PJ *setup(PJ *P) {
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
PJ *PROJECTION(eck3) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->C_x = 0.42223820031577120149;
Q->C_y = 0.84447640063154240298;
Q->A = 1.0;
Q->B = 0.4052847345693510857755;
return setup(P);
}
PJ *PROJECTION(kav7) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
/* Defined twice in original code - Using 0.866...,
* but leaving the other one here as a safety measure.
* Q->C_x = 0.2632401569273184856851; */
Q->C_x = 0.8660254037844;
Q->C_y = 1.;
Q->A = 0.;
Q->B = 0.30396355092701331433;
return setup(P);
}
PJ *PROJECTION(wag6) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->C_x = Q->C_y = 0.94745;
Q->A = 0.0;
Q->B = 0.30396355092701331433;
return setup(P);
}
PJ *PROJECTION(putp1) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->C_x = 1.89490;
Q->C_y = 0.94745;
Q->A = -0.5;
Q->B = 0.30396355092701331433;
return setup(P);
}
#ifndef PJ_SELFTEST
int pj_eck3_selftest (void) {return 0;}
#else
int pj_eck3_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=eck3 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 188652.01572153764, 94328.919337031271},
{ 188652.01572153764, -94328.919337031271},
{-188652.01572153764, 94328.919337031271},
{-188652.01572153764, -94328.919337031271},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0021202405520236059, 0.0010601202759750307},
{ 0.0021202405520236059, -0.0010601202759750307},
{-0.0021202405520236059, 0.0010601202759750307},
{-0.0021202405520236059, -0.0010601202759750307},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_kav7_selftest (void) {return 0;}
#else
int pj_kav7_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=kav7 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 193462.9749437288, 111701.07212763709},
{ 193462.9749437288, -111701.07212763709},
{-193462.9749437288, 111701.07212763709},
{-193462.9749437288, -111701.07212763709}
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0020674833579085268, 0.00089524655489191132},
{ 0.0020674833579085268, -0.00089524655489191132},
{-0.0020674833579085268, 0.00089524655489191132},
{-0.0020674833579085268, -0.00089524655489191132}
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_wag6_selftest (void) {return 0;}
#else
int pj_wag6_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=wag6 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 211652.56216440981, 105831.18078732977},
{ 211652.56216440981, -105831.18078732977},
{-211652.56216440981, 105831.18078732977},
{-211652.56216440981, -105831.18078732977}
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0018898022163257513, 0.000944901108123818},
{ 0.0018898022163257513, -0.000944901108123818},
{-0.0018898022163257513, 0.000944901108123818},
{-0.0018898022163257513, -0.000944901108123818}
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_putp1_selftest (void) {return 0;}
#else
int pj_putp1_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=putp1 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 211642.76275416015, 105831.18078732977},
{ 211642.76275416015, -105831.18078732977},
{-211642.76275416015, 105831.18078732977},
{-211642.76275416015, -105831.18078732977}
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0018898022164038663, 0.000944901108123818},
{ 0.0018898022164038663, -0.000944901108123818},
{-0.0018898022164038663, 0.000944901108123818},
{-0.0018898022164038663, -0.000944901108123818}
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/lib_proj.cmake 0000644 0000000 0000000 00000021306 12761101536 012765 0000000 0000000 ##############################################
### SWITCH BETWEEN STATIC OR SHARED LIBRARY###
##############################################
colormsg(_HIBLUE_ "Configuring proj library:")
message(STATUS "")
# default config, shared on unix and static on Windows
if(UNIX)
set(BUILD_LIBPROJ_SHARED_DEFAULT ON )
endif(UNIX)
if( WIN32)
set(BUILD_LIBPROJ_SHARED_DEFAULT OFF)
endif(WIN32)
option(BUILD_LIBPROJ_SHARED "Build libproj library shared." ${BUILD_LIBPROJ_SHARED_DEFAULT})
if(BUILD_LIBPROJ_SHARED)
set(PROJ_LIBRARY_TYPE SHARED)
else(BUILD_LIBPROJ_SHARED)
set(PROJ_LIBRARY_TYPE STATIC)
endif(BUILD_LIBPROJ_SHARED)
option(USE_THREAD "Build libproj with thread/mutex support " ON)
if(NOT USE_THREAD)
add_definitions( -DMUTEX_stub)
endif(NOT USE_THREAD)
find_package(Threads QUIET)
if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_WIN32_THREADS_INIT )
add_definitions( -DMUTEX_win32)
endif(USE_THREAD AND Threads_FOUND AND CMAKE_USE_WIN32_THREADS_INIT )
if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT )
add_definitions( -DMUTEX_pthread)
endif(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT )
if(USE_THREAD AND NOT Threads_FOUND)
message(FATAL_ERROR "No thread library found and thread/mutex support is required by USE_THREAD option")
endif(USE_THREAD AND NOT Threads_FOUND)
##############################################
### librairie source list and include_list ###
##############################################
SET(SRC_LIBPROJ_PJ
nad_init.c
PJ_aea.c
PJ_aeqd.c
PJ_airy.c
PJ_aitoff.c
PJ_august.c
PJ_bacon.c
PJ_bipc.c
PJ_boggs.c
PJ_bonne.c
PJ_calcofi.c
PJ_cass.c
PJ_cc.c
PJ_cea.c
PJ_chamb.c
PJ_collg.c
PJ_comill.c
PJ_crast.c
PJ_denoy.c
PJ_eck1.c
PJ_eck2.c
PJ_eck3.c
PJ_eck4.c
PJ_eck5.c
PJ_eqc.c
PJ_eqdc.c
PJ_fahey.c
PJ_fouc_s.c
PJ_gall.c
PJ_geos.c
PJ_gins8.c
PJ_gnom.c
PJ_gn_sinu.c
PJ_goode.c
PJ_gstmerc.c
PJ_hammer.c
PJ_hatano.c
PJ_igh.c
PJ_isea.c
PJ_imw_p.c
PJ_krovak.c
PJ_labrd.c
PJ_laea.c
PJ_lagrng.c
PJ_larr.c
PJ_lask.c
PJ_lcca.c
PJ_lcc.c
PJ_loxim.c
PJ_lsat.c
PJ_misrsom.c
PJ_mbt_fps.c
PJ_mbtfpp.c
PJ_mbtfpq.c
PJ_merc.c
PJ_mill.c
PJ_mod_ster.c
PJ_moll.c
PJ_natearth.c
PJ_natearth2.c
PJ_nell.c
PJ_nell_h.c
PJ_nocol.c
PJ_nsper.c
PJ_nzmg.c
PJ_ob_tran.c
PJ_ocea.c
PJ_oea.c
PJ_omerc.c
PJ_ortho.c
PJ_patterson.c
PJ_poly.c
PJ_putp2.c
PJ_putp3.c
PJ_putp4p.c
PJ_putp5.c
PJ_putp6.c
PJ_qsc.c
PJ_robin.c
PJ_rpoly.c
PJ_sch.c
PJ_sconics.c
PJ_somerc.c
PJ_sterea.c
PJ_stere.c
PJ_sts.c
PJ_tcc.c
PJ_tcea.c
PJ_times.c
PJ_tmerc.c
PJ_tpeqd.c
PJ_urm5.c
PJ_urmfps.c
PJ_vandg.c
PJ_vandg2.c
PJ_vandg4.c
PJ_wag2.c
PJ_wag3.c
PJ_wag7.c
PJ_wink1.c
PJ_wink2.c
proj_etmerc.c
)
SET(SRC_LIBPROJ_CORE
aasincos.c
adjlon.c
bch2bps.c
bchgen.c
biveval.c
dmstor.c
emess.c
emess.h
geocent.c
geocent.h
geodesic.c
mk_cheby.c
nad_cvt.c
nad_init.c
nad_intr.c
pj_apply_gridshift.c
pj_apply_vgridshift.c
pj_auth.c
pj_ctx.c
pj_fileapi.c
pj_datum_set.c
pj_datums.c
pj_deriv.c
pj_ell_set.c
pj_ellps.c
pj_errno.c
pj_factors.c
pj_fwd.c
pj_fwd3d.c
pj_gauss.c
pj_gc_reader.c
pj_generic_selftest.c
pj_geocent.c
pj_gridcatalog.c
pj_gridinfo.c
pj_gridlist.c
PJ_healpix.c
pj_init.c
pj_initcache.c
pj_inv.c
pj_inv3d.c
pj_latlong.c
pj_list.c
pj_list.h
pj_log.c
pj_malloc.c
pj_mlfn.c
pj_msfn.c
pj_mutex.c
pj_open_lib.c
pj_param.c
pj_phi2.c
pj_pr_list.c
pj_qsfn.c
pj_release.c
pj_run_selftests.c
pj_strerrno.c
pj_transform.c
pj_tsfn.c
pj_units.c
pj_utils.c
pj_zpoly1.c
proj_mdist.c
proj_rouss.c
rtodms.c
vector1.c
pj_strtod.c
${CMAKE_CURRENT_BINARY_DIR}/proj_config.h
)
set(HEADERS_LIBPROJ
projects.h
proj_api.h
geodesic.h
)
# Group source files for IDE source explorers (e.g. Visual Studio)
source_group("Header Files" FILES ${HEADERS_LIBPROJ})
source_group("Source Files\\Core" FILES ${SRC_LIBPROJ_CORE})
source_group("Source Files\\PJ" FILES ${SRC_LIBPROJ_PJ})
include_directories( ${CMAKE_CURRENT_BINARY_DIR})
source_group("CMake Files" FILES CMakeLists.txt)
# Embed PROJ_LIB data files location
add_definitions(-DPROJ_LIB="${CMAKE_INSTALL_PREFIX}/${DATADIR}")
#################################################
## java wrapping with jni
#################################################
option(JNI_SUPPORT "Build support of java/jni wrapping for proj library" OFF)
find_package(JNI QUIET)
if(JNI_SUPPORT AND NOT JNI_FOUND)
message(FATAL_ERROR "jni support is required but jni is not found")
endif(JNI_SUPPORT AND NOT JNI_FOUND)
boost_report_value(JNI_SUPPORT)
if(JNI_SUPPORT)
set(SRC_LIBPROJ_CORE ${SRC_LIBPROJ_CORE}
jniproj.c )
set(HEADERS_LIBPROJ ${HEADERS_LIBPROJ}
org_proj4_PJ.h
org_proj4_Projections.h)
source_group("Source Files\\JNI" FILES ${SRC_LIBPROJ_JNI})
add_definitions(-DJNI_ENABLED)
include_directories( ${JNI_INCLUDE_DIRS})
boost_report_value(JNI_INCLUDE_DIRS)
endif(JNI_SUPPORT)
#################################################
## targets: libproj and proj_config.h
#################################################
set(ALL_LIBPROJ_SOURCES ${SRC_LIBPROJ_PJ} ${SRC_LIBPROJ_CORE})
set(ALL_LIBPROJ_HEADERS ${HEADERS_LIBPROJ} )
if(WIN32 AND BUILD_LIBPROJ_SHARED)
set(ALL_LIBPROJ_SOURCES ${ALL_LIBPROJ_SOURCES} proj.def )
endif(WIN32 AND BUILD_LIBPROJ_SHARED)
# Core targets configuration
string(TOLOWER "${PROJECT_INTERN_NAME}" PROJECTNAMEL)
set(PROJ_CORE_TARGET ${PROJECTNAMEL})
proj_target_output_name(${PROJ_CORE_TARGET} PROJ_CORE_TARGET_OUTPUT_NAME)
add_library( ${PROJ_CORE_TARGET}
${PROJ_LIBRARY_TYPE}
${ALL_LIBPROJ_SOURCES}
${ALL_LIBPROJ_HEADERS}
${PROJ_RESOURCES} )
if(WIN32)
set_target_properties(${PROJ_CORE_TARGET}
PROPERTIES
VERSION "${${PROJECT_INTERN_NAME}_BUILD_VERSION}"
OUTPUT_NAME "${PROJ_CORE_TARGET_OUTPUT_NAME}"
CLEAN_DIRECT_OUTPUT 1)
elseif(BUILD_FRAMEWORKS_AND_BUNDLE)
set_target_properties(${PROJ_CORE_TARGET}
PROPERTIES
VERSION "${${PROJECT_INTERN_NAME}_BUILD_VERSION}"
INSTALL_NAME_DIR ${PROJ_INSTALL_NAME_DIR}
CLEAN_DIRECT_OUTPUT 1)
else()
set_target_properties(${PROJ_CORE_TARGET}
PROPERTIES
VERSION "${${PROJECT_INTERN_NAME}_BUILD_VERSION}"
SOVERSION "${${PROJECT_INTERN_NAME}_API_VERSION}"
CLEAN_DIRECT_OUTPUT 1)
endif()
set_target_properties(${PROJ_CORE_TARGET}
PROPERTIES
LINKER_LANGUAGE C)
##############################################
# Link properties
##############################################
set(PROJ_LIBRARIES ${PROJ_CORE_TARGET} )
if(UNIX)
find_library(M_LIB m)
if(M_LIB)
TARGET_LINK_LIBRARIES(${PROJ_CORE_TARGET} -lm)
endif()
endif(UNIX)
if(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
TARGET_LINK_LIBRARIES(${PROJ_CORE_TARGET} ${CMAKE_THREAD_LIBS_INIT})
endif(USE_THREAD AND Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
##############################################
# install
##############################################
install(TARGETS ${PROJ_CORE_TARGET}
EXPORT targets
RUNTIME DESTINATION ${BINDIR}
LIBRARY DESTINATION ${LIBDIR}
ARCHIVE DESTINATION ${LIBDIR}
FRAMEWORK DESTINATION ${FRAMEWORKDIR})
if(NOT BUILD_FRAMEWORKS_AND_BUNDLE)
install(FILES ${ALL_LIBPROJ_HEADERS}
DESTINATION ${INCLUDEDIR})
endif(NOT BUILD_FRAMEWORKS_AND_BUNDLE)
##############################################
# Core configuration summary
##############################################
boost_report_value(PROJ_CORE_TARGET)
boost_report_value(PROJ_CORE_TARGET_OUTPUT_NAME)
boost_report_value(PROJ_LIBRARY_TYPE)
boost_report_value(PROJ_LIBRARIES)
proj-4.9.3/src/bin_nad2bin.cmake 0000644 0000000 0000000 00000000750 12761101536 013332 0000000 0000000 if(WIN32 AND BUILD_LIBPROJ_SHARED)
message(warning " nad2nad can't be build with a DLL proj4 library you need a static lib")
endif(WIN32 AND BUILD_LIBPROJ_SHARED)
set(NAD2BIN_SRC nad2bin.c)
source_group("Source Files\\Bin" FILES ${NAD2BIN_SRC})
if(WIN32)
set(NAD2BIN_SRC ${NAD2BIN_SRC} emess.c)
endif(WIN32)
#Executable
add_executable(nad2bin ${NAD2BIN_SRC})
target_link_libraries(nad2bin ${PROJ_LIBRARIES})
install(TARGETS nad2bin
RUNTIME DESTINATION ${BINDIR})
proj-4.9.3/src/PJ_gall.c 0000644 0000000 0000000 00000003732 12761101536 011642 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(gall, "Gall (Gall Stereographic)") "\n\tCyl, Sph";
#define YF 1.70710678118654752440
#define XF 0.70710678118654752440
#define RYF 0.58578643762690495119
#define RXF 1.41421356237309504880
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
(void) P;
xy.x = XF * lp.lam;
xy.y = YF * tan(.5 * lp.phi);
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
(void) P;
lp.lam = RXF * xy.x;
lp.phi = 2. * atan(xy.y * RYF);
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(gall) {
P->es = 0.0;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_gall_selftest (void) {return 0;}
#else
int pj_gall_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=gall +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 157969.17113451968, 95345.249178385886},
{ 157969.17113451968, -95345.249178385886},
{-157969.17113451968, 95345.249178385886},
{-157969.17113451968, -95345.249178385886},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0025321396391918614, 0.001048846580346495},
{ 0.0025321396391918614, -0.001048846580346495},
{-0.0025321396391918614, 0.001048846580346495},
{-0.0025321396391918614, -0.001048846580346495},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_hammer.c 0000644 0000000 0000000 00000005621 12761101536 012173 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(hammer, "Hammer & Eckert-Greifendorff")
"\n\tMisc Sph, \n\tW= M=";
#define EPS 1.0e-10
struct pj_opaque {
double w; \
double m, rm;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double cosphi, d;
d = sqrt(2./(1. + (cosphi = cos(lp.phi)) * cos(lp.lam *= Q->w)));
xy.x = Q->m * d * cosphi * sin(lp.lam);
xy.y = Q->rm * d * sin(lp.phi);
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double z;
z = sqrt(1. - 0.25*Q->w*Q->w*xy.x*xy.x - 0.25*xy.y*xy.y);
if (fabs(2.*z*z-1.) < EPS) {
lp.lam = HUGE_VAL;
lp.phi = HUGE_VAL;
pj_errno = -14;
} else {
lp.lam = aatan2(Q->w * xy.x * z,2. * z * z - 1)/Q->w;
lp.phi = aasin(P->ctx,z * xy.y);
}
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(hammer) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
if (pj_param(P->ctx, P->params, "tW").i) {
if ((Q->w = fabs(pj_param(P->ctx, P->params, "dW").f)) <= 0.) E_ERROR(-27);
} else
Q->w = .5;
if (pj_param(P->ctx, P->params, "tM").i) {
if ((Q->m = fabs(pj_param(P->ctx, P->params, "dM").f)) <= 0.) E_ERROR(-27);
} else
Q->m = 1.;
Q->rm = 1. / Q->m;
Q->m /= Q->w;
P->es = 0.;
P->fwd = s_forward;
P->inv = s_inverse;
return P;
}
#ifndef PJ_SELFTEST
int pj_hammer_selftest (void) {return 0;}
#else
int pj_hammer_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=hammer +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223373.78870324057, 111703.90739776699},
{ 223373.78870324057, -111703.90739776699},
{-223373.78870324057, 111703.90739776699},
{-223373.78870324057, -111703.90739776699},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.001790493109965961, 0.00089524655487369749},
{ 0.001790493109965961, -0.00089524655487369749},
{-0.001790493109965961, 0.00089524655487369749},
{-0.001790493109965961, -0.00089524655487369749},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/org_proj4_Projections.h 0000644 0000000 0000000 00000001751 12761101536 014622 0000000 0000000 /* DO NOT EDIT THIS FILE - it is machine generated */
#include
/* Header for class org_proj4_Projections */
#ifndef _Included_org_proj4_Projections
#define _Included_org_proj4_Projections
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_proj4_Projections
* Method: getProjInfo
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_proj4_Projections_getProjInfo
(JNIEnv *, jobject, jstring);
/*
* Class: org_proj4_Projections
* Method: getEllipsInfo
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_proj4_Projections_getEllipsInfo
(JNIEnv *, jobject, jstring);
/*
* Class: org_proj4_Projections
* Method: transform
* Signature: ([D[D[DLjava/lang/String;Ljava/lang/String;JI)V
*/
JNIEXPORT void JNICALL Java_org_proj4_Projections_transform
(JNIEnv *, jobject, jdoubleArray, jdoubleArray, jdoubleArray, jstring, jstring, jlong, jint);
#ifdef __cplusplus
}
#endif
#endif
proj-4.9.3/src/proj_mdist.c 0000644 0000000 0000000 00000006231 12761101536 012501 0000000 0000000 /*
** libproj -- library of cartographic projections
**
** Copyright (c) 2003, 2006 Gerald I. Evenden
*/
/*
** 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.
*/
/* Computes distance from equator along the meridian to latitude phi
** and inverse on unit ellipsoid.
** Precision commensurate with double precision.
*/
#define PROJ_LIB__
#include
#define MAX_ITER 20
#define TOL 1e-14
struct MDIST {
int nb;
double es;
double E;
double b[1];
};
#define B ((struct MDIST *)b)
void *
proj_mdist_ini(double es) {
double numf, numfi, twon1, denf, denfi, ens, T, twon;
double den, El, Es;
double E[MAX_ITER];
struct MDIST *b;
int i, j;
/* generate E(e^2) and its terms E[] */
ens = es;
numf = twon1 = denfi = 1.;
denf = 1.;
twon = 4.;
Es = El = E[0] = 1.;
for (i = 1; i < MAX_ITER ; ++i) {
numf *= (twon1 * twon1);
den = twon * denf * denf * twon1;
T = numf/den;
Es -= (E[i] = T * ens);
ens *= es;
twon *= 4.;
denf *= ++denfi;
twon1 += 2.;
if (Es == El) /* jump out if no change */
break;
El = Es;
}
if ((b = (struct MDIST *)malloc(sizeof(struct MDIST)+
(i*sizeof(double)))) == NULL)
return(NULL);
b->nb = i - 1;
b->es = es;
b->E = Es;
/* generate b_n coefficients--note: collapse with prefix ratios */
b->b[0] = Es = 1. - Es;
numf = denf = 1.;
numfi = 2.;
denfi = 3.;
for (j = 1; j < i; ++j) {
Es -= E[j];
numf *= numfi;
denf *= denfi;
b->b[j] = Es * numf / denf;
numfi += 2.;
denfi += 2.;
}
return (b);
}
double
proj_mdist(double phi, double sphi, double cphi, const void *b) {
double sc, sum, sphi2, D;
int i;
sc = sphi * cphi;
sphi2 = sphi * sphi;
D = phi * B->E - B->es * sc / sqrt(1. - B->es * sphi2);
sum = B->b[i = B->nb];
while (i) sum = B->b[--i] + sphi2 * sum;
return(D + sc * sum);
}
double
proj_inv_mdist(projCtx ctx, double dist, const void *b) {
double s, t, phi, k;
int i;
k = 1./(1.- B->es);
i = MAX_ITER;
phi = dist;
while ( i-- ) {
s = sin(phi);
t = 1. - B->es * s * s;
phi -= t = (proj_mdist(phi, s, cos(phi), b) - dist) *
(t * sqrt(t)) * k;
if (fabs(t) < TOL) /* that is no change */
return phi;
}
/* convergence failed */
pj_ctx_set_errno(ctx, -17);
return phi;
}
proj-4.9.3/src/PJ_wag7.c 0000644 0000000 0000000 00000002650 12761101536 011566 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(wag7, "Wagner VII") "\n\tMisc Sph, no inv.";
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0, 0.0};
double theta, ct, D;
(void) P; /* Shut up compiler warnnings about unused P */
theta = asin (xy.y = 0.90630778703664996 * sin(lp.phi));
xy.x = 2.66723 * (ct = cos (theta)) * sin (lp.lam /= 3.);
xy.y *= 1.24104 * (D = 1/(sqrt (0.5 * (1 + ct * cos (lp.lam)))));
xy.x *= D;
return (xy);
}
static void *freeup_new (PJ *P) { /* Destructor */
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(wag7) {
P->fwd = s_forward;
P->inv = 0;
P->es = 0.;
return P;
}
#ifndef PJ_SELFTEST
int pj_wag7_selftest (void) {return 0;}
#else
int pj_wag7_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=wag7 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 198601.87695731167, 125637.0457141714},
{ 198601.87695731167, -125637.0457141714},
{-198601.87695731167, 125637.0457141714},
{-198601.87695731167, -125637.0457141714},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/PJ_mbtfpp.c 0000644 0000000 0000000 00000005102 12761101536 012204 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(mbtfpp, "McBride-Thomas Flat-Polar Parabolic") "\n\tCyl., Sph.";
#define CS .95257934441568037152
#define FXC .92582009977255146156
#define FYC 3.40168025708304504493
#define C23 .66666666666666666666
#define C13 .33333333333333333333
#define ONEEPS 1.0000001
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
(void) P;
lp.phi = asin(CS * sin(lp.phi));
xy.x = FXC * lp.lam * (2. * cos(C23 * lp.phi) - 1.);
xy.y = FYC * sin(C13 * lp.phi);
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
lp.phi = xy.y / FYC;
if (fabs(lp.phi) >= 1.) {
if (fabs(lp.phi) > ONEEPS)
I_ERROR
else
lp.phi = (lp.phi < 0.) ? -M_HALFPI : M_HALFPI;
} else
lp.phi = asin(lp.phi);
lp.lam = xy.x / ( FXC * (2. * cos(C23 * (lp.phi *= 3.)) - 1.) );
if (fabs(lp.phi = sin(lp.phi) / CS) >= 1.) {
if (fabs(lp.phi) > ONEEPS)
I_ERROR
else
lp.phi = (lp.phi < 0.) ? -M_HALFPI : M_HALFPI;
} else
lp.phi = asin(lp.phi);
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(mbtfpp) {
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_mbtfpp_selftest (void) {return 0;}
#else
int pj_mbtfpp_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=mbtfpp +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{206804.786929820373, 120649.762565792524},
{206804.786929820373, -120649.762565792524},
{-206804.786929820373, 120649.762565792524},
{-206804.786929820373, -120649.762565792524},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{0.00193395359462902698, 0.00082883725477665357},
{0.00193395359462902698, -0.00082883725477665357},
{-0.00193395359462902698, 0.00082883725477665357},
{-0.00193395359462902698, -0.00082883725477665357},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/nad_cvt.c 0000644 0000000 0000000 00000004305 12761101536 011745 0000000 0000000 #define PJ_LIB__
#include
#define MAX_TRY 9
#define TOL 1e-12
LP
nad_cvt(LP in, int inverse, struct CTABLE *ct) {
LP t, tb;
if (in.lam == HUGE_VAL)
return in;
/* normalize input to ll origin */
tb = in;
tb.lam -= ct->ll.lam;
tb.phi -= ct->ll.phi;
tb.lam = adjlon(tb.lam - M_PI) + M_PI;
t = nad_intr(tb, ct);
if (inverse) {
LP del, dif;
int i = MAX_TRY;
if (t.lam == HUGE_VAL) return t;
t.lam = tb.lam + t.lam;
t.phi = tb.phi - t.phi;
do {
del = nad_intr(t, ct);
/* This case used to return failure, but I have
changed it to return the first order approximation
of the inverse shift. This avoids cases where the
grid shift *into* this grid came from another grid.
While we aren't returning optimally correct results
I feel a close result in this case is better than
no result. NFW
To demonstrate use -112.5839956 49.4914451 against
the NTv2 grid shift file from Canada. */
if (del.lam == HUGE_VAL)
{
if( getenv( "PROJ_DEBUG" ) != NULL )
fprintf( stderr,
"Inverse grid shift iteration failed, presumably at grid edge.\n"
"Using first approximation.\n" );
/* return del */;
break;
}
t.lam -= dif.lam = t.lam - del.lam - tb.lam;
t.phi -= dif.phi = t.phi + del.phi - tb.phi;
} while (i-- && fabs(dif.lam) > TOL && fabs(dif.phi) > TOL);
if (i < 0) {
if( getenv( "PROJ_DEBUG" ) != NULL )
fprintf( stderr,
"Inverse grid shift iterator failed to converge.\n" );
t.lam = t.phi = HUGE_VAL;
return t;
}
in.lam = adjlon(t.lam + ct->ll.lam);
in.phi = t.phi + ct->ll.phi;
} else {
if (t.lam == HUGE_VAL)
in = t;
else {
in.lam -= t.lam;
in.phi += t.phi;
}
}
return in;
}
proj-4.9.3/src/geod_interface.h 0000644 0000000 0000000 00000001627 12761101536 013276 0000000 0000000 #if !defined(GEOD_INTERFACE_H)
#define GEOD_INTERFACE_H
#include "geodesic.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _IN_GEOD_SET
# define GEOD_EXTERN extern
#else
# define GEOD_EXTERN
#endif
GEOD_EXTERN struct geodesic {
double A, FLAT, LAM1, PHI1, ALPHA12, LAM2, PHI2, ALPHA21, DIST;
} GEODESIC;
# define geod_a GEODESIC.A
# define geod_f GEODESIC.FLAT
# define lam1 GEODESIC.LAM1
# define phi1 GEODESIC.PHI1
# define al12 GEODESIC.ALPHA12
# define lam2 GEODESIC.LAM2
# define phi2 GEODESIC.PHI2
# define al21 GEODESIC.ALPHA21
# define geod_S GEODESIC.DIST
GEOD_EXTERN struct geod_geodesic GlobalGeodesic;
GEOD_EXTERN struct geod_geodesicline GlobalGeodesicLine;
GEOD_EXTERN int n_alpha, n_S;
GEOD_EXTERN double to_meter, fr_meter, del_alpha;
void geod_set(int, char **);
void geod_ini(void);
void geod_pre(void);
void geod_for(void);
void geod_inv(void);
#ifdef __cplusplus
}
#endif
#endif
proj-4.9.3/src/bch2bps.c 0000644 0000000 0000000 00000007020 12761101536 011647 0000000 0000000 /* convert bivariate w Chebyshev series to w Power series */
#include
/* basic support procedures */
static void /* clear vector to zero */
clear(projUV *p, int n) { static const projUV c = {0., 0.}; while (n--) *p++ = c; }
static void /* clear matrix rows to zero */
bclear(projUV **p, int n, int m) { while (n--) clear(*p++, m); }
static void /* move vector */
bmove(projUV *a, projUV *b, int n) { while (n--) *a++ = *b++; }
static void /* a <- m * b - c */
submop(projUV *a, double m, projUV *b, projUV *c, int n) {
while (n--) {
a->u = m * b->u - c->u;
a++->v = m * b++->v - c++->v;
}
}
static void /* a <- b - c */
subop(projUV *a, projUV *b, projUV *c, int n) {
while (n--) {
a->u = b->u - c->u;
a++->v = b++->v - c++->v;
}
}
static void /* multiply vector a by scalar m */
dmult(projUV *a, double m, int n) { while(n--) { a->u *= m; a->v *= m; ++a; } }
static void /* row adjust a[] <- a[] - m * b[] */
dadd(projUV *a, projUV *b, double m, int n) {
while(n--) {
a->u -= m * b->u;
a++->v -= m * b++->v;
}
}
static void /* convert row to pover series */
rows(projUV *c, projUV *d, int n) {
projUV sv, *dd;
int j, k;
dd = (projUV *)vector1(n-1, sizeof(projUV));
sv.u = sv.v = 0.;
for (j = 0; j < n; ++j) d[j] = dd[j] = sv;
d[0] = c[n-1];
for (j = n-2; j >= 1; --j) {
for (k = n-j; k >= 1; --k) {
sv = d[k];
d[k].u = 2. * d[k-1].u - dd[k].u;
d[k].v = 2. * d[k-1].v - dd[k].v;
dd[k] = sv;
}
sv = d[0];
d[0].u = -dd[0].u + c[j].u;
d[0].v = -dd[0].v + c[j].v;
dd[0] = sv;
}
for (j = n-1; j >= 1; --j) {
d[j].u = d[j-1].u - dd[j].u;
d[j].v = d[j-1].v - dd[j].v;
}
d[0].u = -dd[0].u + .5 * c[0].u;
d[0].v = -dd[0].v + .5 * c[0].v;
pj_dalloc(dd);
}
static void /* convert columns to power series */
cols(projUV **c, projUV **d, int nu, int nv) {
projUV *sv, **dd;
int j, k;
dd = (projUV **)vector2(nu, nv, sizeof(projUV));
sv = (projUV *)vector1(nv, sizeof(projUV));
bclear(d, nu, nv);
bclear(dd, nu, nv);
bmove(d[0], c[nu-1], nv);
for (j = nu-2; j >= 1; --j) {
for (k = nu-j; k >= 1; --k) {
bmove(sv, d[k], nv);
submop(d[k], 2., d[k-1], dd[k], nv);
bmove(dd[k], sv, nv);
}
bmove(sv, d[0], nv);
subop(d[0], c[j], dd[0], nv);
bmove(dd[0], sv, nv);
}
for (j = nu-1; j >= 1; --j)
subop(d[j], d[j-1], dd[j], nv);
submop(d[0], .5, c[0], dd[0], nv);
freev2((void **) dd, nu);
pj_dalloc(sv);
}
static void /* row adjust for range -1 to 1 to a to b */
rowshft(double a, double b, projUV *d, int n) {
int k, j;
double fac, cnst;
cnst = 2. / (b - a);
fac = cnst;
for (j = 1; j < n; ++j) {
d[j].u *= fac;
d[j].v *= fac;
fac *= cnst;
}
cnst = .5 * (a + b);
for (j = 0; j <= n-2; ++j)
for (k = n - 2; k >= j; --k) {
d[k].u -= cnst * d[k+1].u;
d[k].v -= cnst * d[k+1].v;
}
}
static void /* column adjust for range -1 to 1 to a to b */
colshft(double a, double b, projUV **d, int n, int m) {
int k, j;
double fac, cnst;
cnst = 2. / (b - a);
fac = cnst;
for (j = 1; j < n; ++j) {
dmult(d[j], fac, m);
fac *= cnst;
}
cnst = .5 * (a + b);
for (j = 0; j <= n-2; ++j)
for (k = n - 2; k >= j; --k)
dadd(d[k], d[k+1], cnst, m);
}
int /* entry point */
bch2bps(projUV a, projUV b, projUV **c, int nu, int nv) {
projUV **d;
int i;
if (nu < 1 || nv < 1 || !(d = (projUV **)vector2(nu, nv, sizeof(projUV))))
return 0;
/* do rows to power series */
for (i = 0; i < nu; ++i) {
rows(c[i], d[i], nv);
rowshft(a.v, b.v, d[i], nv);
}
/* do columns to power series */
cols(d, c, nu, nv);
colshft(a.u, b.u, c, nu, nv);
freev2((void **) d, nu);
return 1;
}
proj-4.9.3/src/PJ_eqc.c 0000644 0000000 0000000 00000004401 12761101536 011465 0000000 0000000 #define PJ_LIB__
#include
struct pj_opaque {
double rc;
};
PROJ_HEAD(eqc, "Equidistant Cylindrical (Plate Caree)")
"\n\tCyl, Sph\n\tlat_ts=[, lat_0=0]";
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
xy.x = Q->rc * lp.lam;
xy.y = lp.phi - P->phi0;
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
lp.lam = xy.x / Q->rc;
lp.phi = xy.y + P->phi0;
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(eqc) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
if ((Q->rc = cos(pj_param(P->ctx, P->params, "rlat_ts").f)) <= 0.) E_ERROR(-24);
P->inv = s_inverse;
P->fwd = s_forward;
P->es = 0.;
return P;
}
#ifndef PJ_SELFTEST
int pj_eqc_selftest (void) {return 0;}
#else
int pj_eqc_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=eqc +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223402.144255274179, 111701.07212763709},
{ 223402.144255274179, -111701.07212763709},
{-223402.144255274179, 111701.07212763709},
{-223402.144255274179, -111701.07212763709},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00179049310978382265, 0.000895246554891911323},
{ 0.00179049310978382265, -0.000895246554891911323},
{-0.00179049310978382265, 0.000895246554891911323},
{-0.00179049310978382265, -0.000895246554891911323},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_lask.c 0000644 0000000 0000000 00000003245 12761101536 011654 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(lask, "Laskowski") "\n\tMisc Sph, no inv.";
#define a10 0.975534
#define a12 -0.119161
#define a32 -0.0143059
#define a14 -0.0547009
#define b01 1.00384
#define b21 0.0802894
#define b03 0.0998909
#define b41 0.000199025
#define b23 -0.0285500
#define b05 -0.0491032
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
double l2, p2;
(void) P;
l2 = lp.lam * lp.lam;
p2 = lp.phi * lp.phi;
xy.x = lp.lam * (a10 + p2 * (a12 + l2 * a32 + p2 * a14));
xy.y = lp.phi * (b01 + l2 * (b21 + p2 * b23 + l2 * b41) +
p2 * (b03 + p2 * b05));
return xy;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(lask) {
P->fwd = s_forward;
P->es = 0.;
return P;
}
#ifndef PJ_SELFTEST
int pj_lask_selftest (void) {return 0;}
#else
int pj_lask_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=lask +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 217928.275907355128, 112144.32922014239},
{ 217928.275907355128, -112144.32922014239},
{-217928.275907355128, 112144.32922014239},
{-217928.275907355128, -112144.32922014239},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/makefile.vc 0000644 0000000 0000000 00000012070 12761101536 012270 0000000 0000000 #
# makefile.vc - builds PROJ.4 library with Visual C++
#
!INCLUDE ..\nmake.opt
azimuthal = \
PJ_aeqd.obj PJ_gnom.obj PJ_laea.obj PJ_mod_ster.obj \
PJ_nsper.obj PJ_nzmg.obj PJ_ortho.obj PJ_stere.obj PJ_sterea.obj \
proj_rouss.obj
conic = \
PJ_aea.obj PJ_bipc.obj PJ_bonne.obj PJ_eqdc.obj \
PJ_imw_p.obj PJ_lcc.obj PJ_poly.obj \
PJ_rpoly.obj PJ_sconics.obj PJ_lcca.obj
cylinder = \
PJ_cass.obj PJ_cc.obj PJ_cea.obj PJ_eqc.obj \
PJ_gall.obj PJ_labrd.obj PJ_lsat.obj PJ_misrsom.obj PJ_merc.obj \
PJ_mill.obj PJ_ocea.obj PJ_omerc.obj PJ_patterson.obj PJ_somerc.obj \
PJ_tcc.obj PJ_tcea.obj PJ_tmerc.obj PJ_geos.obj \
PJ_gstmerc.obj proj_etmerc.obj PJ_comill.obj
misc = \
PJ_airy.obj PJ_aitoff.obj PJ_august.obj PJ_bacon.obj \
PJ_chamb.obj PJ_hammer.obj PJ_lagrng.obj PJ_larr.obj \
PJ_lask.obj PJ_nocol.obj PJ_ob_tran.obj PJ_oea.obj \
PJ_sch.obj PJ_tpeqd.obj PJ_vandg.obj PJ_vandg2.obj \
PJ_vandg4.obj PJ_wag7.obj pj_latlong.obj PJ_krovak.obj \
pj_geocent.obj PJ_healpix.obj PJ_qsc.obj
pseudo = \
PJ_boggs.obj PJ_collg.obj PJ_crast.obj PJ_denoy.obj \
PJ_eck1.obj PJ_eck2.obj PJ_eck3.obj PJ_eck4.obj \
PJ_eck5.obj PJ_fahey.obj PJ_fouc_s.obj PJ_gins8.obj \
PJ_gn_sinu.obj PJ_goode.obj PJ_igh.obj PJ_hatano.obj PJ_loxim.obj \
PJ_mbt_fps.obj PJ_mbtfpp.obj PJ_mbtfpq.obj PJ_moll.obj \
PJ_nell.obj PJ_nell_h.obj PJ_putp2.obj PJ_putp3.obj \
PJ_putp4p.obj PJ_putp5.obj PJ_putp6.obj PJ_robin.obj \
PJ_sts.obj PJ_urm5.obj PJ_urmfps.obj PJ_wag2.obj \
PJ_wag3.obj PJ_wink1.obj PJ_wink2.obj PJ_isea.obj \
PJ_calcofi.obj PJ_natearth.obj PJ_natearth2.obj PJ_times.obj
support = \
aasincos.obj adjlon.obj bch2bps.obj bchgen.obj pj_gauss.obj \
biveval.obj dmstor.obj mk_cheby.obj pj_auth.obj \
pj_deriv.obj pj_ell_set.obj pj_ellps.obj pj_errno.obj \
pj_factors.obj pj_fwd.obj pj_init.obj pj_inv.obj \
pj_fwd3d.obj pj_inv3d.obj \
pj_list.obj pj_malloc.obj pj_mlfn.obj pj_msfn.obj \
pj_open_lib.obj pj_param.obj pj_phi2.obj pj_pr_list.obj \
pj_qsfn.obj pj_strerrno.obj pj_tsfn.obj pj_units.obj \
pj_zpoly1.obj rtodms.obj vector1.obj pj_release.obj \
geocent.obj pj_transform.obj pj_datum_set.obj pj_datums.obj \
pj_apply_gridshift.obj pj_gc_reader.obj pj_gridcatalog.obj \
nad_cvt.obj nad_init.obj nad_intr.obj \
pj_utils.obj pj_gridlist.obj pj_gridinfo.obj \
proj_mdist.obj pj_mutex.obj pj_initcache.obj \
pj_ctx.obj pj_fileapi.obj pj_log.obj pj_apply_vgridshift.obj \
pj_strtod.obj pj_run_selftests.obj pj_generic_selftest.obj
geodesic = geodesic.obj
LIBOBJ = $(support) $(pseudo) $(azimuthal) $(conic) $(cylinder) $(misc) \
$(geodesic)
PROJEXE_OBJ = proj.obj gen_cheb.obj p_series.obj emess.obj
CS2CSEXE_OBJ = cs2cs.obj gen_cheb.obj p_series.obj emess.obj
GEODEXE_OBJ = geod.obj geod_set.obj geod_interface.obj emess.obj
MULTISTRESSTEST_OBJ = multistresstest.obj
PROJ_DLL = proj$(VERSION).dll
PROJ_EXE = proj.exe
CS2CS_EXE = cs2cs.exe
GEOD_EXE = geod.exe
NAD2BIN_EXE = nad2bin.exe
MULTISTRESSTEST_EXE = multistresstest.exe
CFLAGS = /nologo -I. -DPROJ_LIB=\"$(PROJ_LIB_DIR)\" \
-DHAVE_STRERROR=1 -DHAVE_LOCALECONV=1 $(OPTFLAGS)
default: all
all: proj.lib $(PROJ_EXE) $(CS2CS_EXE) $(GEOD_EXE) $(NAD2BIN_EXE)
proj.lib: $(LIBOBJ)
if exist proj.lib del proj.lib
lib /out:proj.lib $(LIBOBJ)
$(PROJ_DLL): proj_i.lib
proj_i.lib: $(LIBOBJ)
link /debug /dll /def:proj.def /out:$(PROJ_DLL) /implib:proj_i.lib \
$(LIBOBJ)
if exist $(PROJ_DLL).manifest mt -manifest $(PROJ_DLL).manifest -outputresource:$(PROJ_DLL);2
$(PROJ_EXE): $(PROJEXE_OBJ) $(EXE_PROJ)
cl $(PROJEXE_OBJ) $(EXE_PROJ)
if exist $(PROJ_EXE).manifest mt -manifest $(PROJ_EXE).manifest -outputresource:$(PROJ_EXE);1
$(CS2CS_EXE): $(CS2CSEXE_OBJ) $(EXE_PROJ)
cl $(CS2CSEXE_OBJ) $(EXE_PROJ)
if exist $(CS2CS_EXE).manifest mt -manifest $(CS2CS_EXE).manifest -outputresource:$(CS2CS_EXE);1
$(GEOD_EXE): $(GEODEXE_OBJ) $(EXE_PROJ)
cl $(GEODEXE_OBJ) $(EXE_PROJ)
if exist $(GEOD_EXE).manifest mt -manifest $(GEOD_EXE).manifest -outputresource:$(GEOD_EXE);1
$(NAD2BIN_EXE): nad2bin.obj emess.obj $(EXE_PROJ)
cl nad2bin.obj emess.obj $(EXE_PROJ)
$(MULTISTRESSTEST_EXE): $(MULTISTRESSTEST_OBJ)
cl $(MULTISTRESSTEST_OBJ) $(EXE_PROJ)
if exist $(MULTISTRESSTEST_EXE).manifest mt -manifest $(MULTISTRESSTEST_EXE).manifest -outputresource:$(MULTISTRESSTEST_EXE);1
nadshift: nad2bin.exe
cd ..\nad
..\src\nad2bin.exe < conus.lla conus
..\src\nad2bin.exe < MD.lla MD
..\src\nad2bin.exe < TN.lla TN
..\src\nad2bin.exe < WI.lla WI
..\src\nad2bin.exe < WO.lla WO
..\src\nad2bin.exe < alaska.lla alaska
..\src\nad2bin.exe < hawaii.lla hawaii
..\src\nad2bin.exe < prvi.lla prvi
..\src\nad2bin.exe < stgeorge.lla stgeorge
..\src\nad2bin.exe < stlrnc.lla stlrnc
..\src\nad2bin.exe < stpaul.lla stpaul
..\src\nad2bin.exe < null.lla null
cd ..\src
clean:
del *.dll
del *.exe
del *.exp
del *.manifest
del *.lib
del *.obj
del *.pdb
install: all
-mkdir $(INSTDIR)
-mkdir $(INSTDIR)\bin
-mkdir $(INSTDIR)\share
-mkdir $(INSTDIR)\lib
-mkdir $(INSTDIR)\include
copy *.exe $(INSTDIR)\bin
copy *.dll $(INSTDIR)\bin
copy *.lib $(INSTDIR)\lib
copy proj_api.h $(INSTDIR)\include
copy projects.h $(INSTDIR)\include
copy geodesic.h $(INSTDIR)\include
proj-4.9.3/src/bin_geodtest.cmake 0000644 0000000 0000000 00000000526 12761101536 013634 0000000 0000000 set(GEODTEST_SRC geodtest.c )
set(GEODTEST_INCLUDE)
source_group("Source Files\\Bin" FILES ${GEODTEST_SRC} ${GEODTEST_INCLUDE})
#Executable
add_executable(geodtest ${GEODTEST_SRC} ${GEODTEST_INCLUDE})
target_link_libraries(geodtest ${PROJ_LIBRARIES})
# Do not install
# Instead run as a test
add_test (NAME geodesic-test COMMAND geodtest)
proj-4.9.3/src/pj_open_lib.c 0000644 0000000 0000000 00000013435 12761101536 012613 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Implementation of pj_open_lib(), and pj_set_finder(). These
* provide a standard interface for opening projections support
* data files.
* Author: Gerald Evenden, Frank Warmerdam
*
******************************************************************************
* Copyright (c) 1995, Gerald Evenden
* Copyright (c) 2002, 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.
*****************************************************************************/
#define PJ_LIB__
#include
#include
#include
#include
static const char *(*pj_finder)(const char *) = NULL;
static int path_count = 0;
static char **search_path = NULL;
static char * proj_lib_name =
#ifdef PROJ_LIB
PROJ_LIB;
#else
0;
#endif
/************************************************************************/
/* pj_set_finder() */
/************************************************************************/
void pj_set_finder( const char *(*new_finder)(const char *) )
{
pj_finder = new_finder;
}
/************************************************************************/
/* pj_set_searchpath() */
/* */
/* Path control for callers that can't practically provide */
/* pj_set_finder() style callbacks. Call with (0,NULL) as args */
/* to clear the searchpath set. */
/************************************************************************/
void pj_set_searchpath ( int count, const char **path )
{
int i;
if (path_count > 0 && search_path != NULL)
{
for (i = 0; i < path_count; i++)
{
pj_dalloc(search_path[i]);
}
pj_dalloc(search_path);
path_count = 0;
search_path = NULL;
}
if( count > 0 )
{
search_path = pj_malloc(sizeof *search_path * count);
for (i = 0; i < count; i++)
{
search_path[i] = pj_malloc(strlen(path[i]) + 1);
strcpy(search_path[i], path[i]);
}
}
path_count = count;
}
/************************************************************************/
/* pj_open_lib() */
/************************************************************************/
PAFile
pj_open_lib(projCtx ctx, const char *name, const char *mode) {
char fname[MAX_PATH_FILENAME+1];
const char *sysname;
PAFile fid;
int n = 0;
int i;
#ifdef WIN32
static const char dir_chars[] = "/\\";
#else
static const char dir_chars[] = "/";
#endif
#ifndef _WIN32_WCE
/* check if ~/name */
if (*name == '~' && strchr(dir_chars,name[1]) )
if ((sysname = getenv("HOME")) != NULL) {
(void)strcpy(fname, sysname);
fname[n = strlen(fname)] = DIR_CHAR;
fname[++n] = '\0';
(void)strcpy(fname+n, name + 1);
sysname = fname;
} else
return NULL;
/* or fixed path: /name, ./name or ../name */
else if (strchr(dir_chars,*name)
|| (*name == '.' && strchr(dir_chars,name[1]))
|| (!strncmp(name, "..", 2) && strchr(dir_chars,name[2]))
|| (name[1] == ':' && strchr(dir_chars,name[2])) )
sysname = name;
/* or try to use application provided file finder */
else if( pj_finder != NULL && pj_finder( name ) != NULL )
sysname = pj_finder( name );
/* or is environment PROJ_LIB defined */
else if ((sysname = getenv("PROJ_LIB")) || (sysname = proj_lib_name)) {
(void)strcpy(fname, sysname);
fname[n = strlen(fname)] = DIR_CHAR;
fname[++n] = '\0';
(void)strcpy(fname+n, name);
sysname = fname;
} else /* just try it bare bones */
sysname = name;
if ((fid = pj_ctx_fopen(ctx, sysname, mode)) != NULL)
errno = 0;
/* If none of those work and we have a search path, try it */
if (!fid && path_count > 0)
{
for (i = 0; fid == NULL && i < path_count; i++)
{
sprintf(fname, "%s%c%s", search_path[i], DIR_CHAR, name);
sysname = fname;
fid = pj_ctx_fopen(ctx, sysname, mode);
}
if (fid)
errno = 0;
}
if( ctx->last_errno == 0 && errno != 0 )
pj_ctx_set_errno( ctx, errno );
pj_log( ctx, PJ_LOG_DEBUG_MAJOR,
"pj_open_lib(%s): call fopen(%s) - %s\n",
name, sysname,
fid == NULL ? "failed" : "succeeded" );
return(fid);
#else
return NULL;
#endif /* _WIN32_WCE */
}
proj-4.9.3/src/PJ_krovak.c 0000644 0000000 0000000 00000020360 12761101536 012214 0000000 0000000 /*
* Project: PROJ.4
* Purpose: Implementation of the krovak (Krovak) projection.
* Definition: http://www.ihsenergy.com/epsg/guid7.html#1.4.3
* Author: Thomas Flemming, tf@ttqv.com
*
******************************************************************************
* Copyright (c) 2001, Thomas Flemming, tf@ttqv.com
*
* 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.
******************************************************************************
* A description of the (forward) projection is found in:
*
* Bohuslav Veverka,
*
* KROVAK’S PROJECTION AND ITS USE FOR THE
* CZECH REPUBLIC AND THE SLOVAK REPUBLIC,
*
* 50 years of the Research Institute of
* and the Slovak Republic Geodesy, Topography and Cartography
*
* which can be found via the Wayback Machine:
*
* https://web.archive.org/web/20150216143806/https://www.vugtk.cz/odis/sborniky/sb2005/Sbornik_50_let_VUGTK/Part_1-Scientific_Contribution/16-Veverka.pdf
*
* Further info, including the inverse projection, is given by EPSG:
*
* Guidance Note 7 part 2
* Coordinate Conversions and Transformations including Formulas
*
* http://www.iogp.org/pubs/373-07-2.pdf
*
* Variable names in this file mostly follows what is used in the
* paper by Veverka.
*
* According to EPSG the full Krovak projection method should have
* the following parameters. Within PROJ.4 the azimuth, and pseudo
* standard parallel are hardcoded in the algorithm and can't be
* altered from outside. The others all have defaults to match the
* common usage with Krovak projection.
*
* lat_0 = latitude of centre of the projection
*
* lon_0 = longitude of centre of the projection
*
* ** = azimuth (true) of the centre line passing through the
* centre of the projection
*
* ** = latitude of pseudo standard parallel
*
* k = scale factor on the pseudo standard parallel
*
* x_0 = False Easting of the centre of the projection at the
* apex of the cone
*
* y_0 = False Northing of the centre of the projection at
* the apex of the cone
*
*****************************************************************************/
#define PJ_LIB__
#include
PROJ_HEAD(krovak, "Krovak") "\n\tPCyl., Ellps.";
#define EPS 1e-15
#define S45 0.785398163397448 /* 45 deg */
#define S90 1.570796326794896 /* 90 deg */
#define UQ 1.04216856380474 /* DU(2, 59, 42, 42.69689) */
#define S0 1.37008346281555 /* Latitude of pseudo standard parallel 78deg 30'00" N */
struct pj_opaque {
double alpha;
double k;
double n;
double rho0;
double ad;
int czech;
};
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
struct pj_opaque *Q = P->opaque;
XY xy = {0.0,0.0};
double gfi, u, deltav, s, d, eps, rho;
gfi = pow ( (1. + P->e * sin(lp.phi)) / (1. - P->e * sin(lp.phi)), Q->alpha * P->e / 2.);
u = 2. * (atan(Q->k * pow( tan(lp.phi / 2. + S45), Q->alpha) / gfi)-S45);
deltav = -lp.lam * Q->alpha;
s = asin(cos(Q->ad) * sin(u) + sin(Q->ad) * cos(u) * cos(deltav));
d = asin(cos(u) * sin(deltav) / cos(s));
eps = Q->n * d;
rho = Q->rho0 * pow(tan(S0 / 2. + S45) , Q->n) / pow(tan(s / 2. + S45) , Q->n);
xy.y = rho * cos(eps);
xy.x = rho * sin(eps);
xy.y *= Q->czech;
xy.x *= Q->czech;
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
struct pj_opaque *Q = P->opaque;
LP lp = {0.0,0.0};
double u, deltav, s, d, eps, rho, fi1, xy0;
int ok;
xy0 = xy.x;
xy.x = xy.y;
xy.y = xy0;
xy.x *= Q->czech;
xy.y *= Q->czech;
rho = sqrt(xy.x * xy.x + xy.y * xy.y);
eps = atan2(xy.y, xy.x);
d = eps / sin(S0);
s = 2. * (atan( pow(Q->rho0 / rho, 1. / Q->n) * tan(S0 / 2. + S45)) - S45);
u = asin(cos(Q->ad) * sin(s) - sin(Q->ad) * cos(s) * cos(d));
deltav = asin(cos(s) * sin(d) / cos(u));
lp.lam = P->lam0 - deltav / Q->alpha;
/* ITERATION FOR lp.phi */
fi1 = u;
ok = 0;
do {
lp.phi = 2. * ( atan( pow( Q->k, -1. / Q->alpha) *
pow( tan(u / 2. + S45) , 1. / Q->alpha) *
pow( (1. + P->e * sin(fi1)) / (1. - P->e * sin(fi1)) , P->e / 2.)
) - S45);
if (fabs(fi1 - lp.phi) < EPS) ok=1;
fi1 = lp.phi;
} while (ok==0);
lp.lam -= P->lam0;
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc(P);
pj_dealloc(P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(krovak) {
double u0, n0, g;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
/* we want Bessel as fixed ellipsoid */
P->a = 6377397.155;
P->e = sqrt(P->es = 0.006674372230614);
/* if latitude of projection center is not set, use 49d30'N */
if (!pj_param(P->ctx, P->params, "tlat_0").i)
P->phi0 = 0.863937979737193;
/* if center long is not set use 42d30'E of Ferro - 17d40' for Ferro */
/* that will correspond to using longitudes relative to greenwich */
/* as input and output, instead of lat/long relative to Ferro */
if (!pj_param(P->ctx, P->params, "tlon_0").i)
P->lam0 = 0.7417649320975901 - 0.308341501185665;
/* if scale not set default to 0.9999 */
if (!pj_param(P->ctx, P->params, "tk").i)
P->k0 = 0.9999;
Q->czech = 1;
if( !pj_param(P->ctx, P->params, "tczech").i )
Q->czech = -1;
/* Set up shared parameters between forward and inverse */
Q->alpha = sqrt(1. + (P->es * pow(cos(P->phi0), 4)) / (1. - P->es));
u0 = asin(sin(P->phi0) / Q->alpha);
g = pow( (1. + P->e * sin(P->phi0)) / (1. - P->e * sin(P->phi0)) , Q->alpha * P->e / 2. );
Q->k = tan( u0 / 2. + S45) / pow (tan(P->phi0 / 2. + S45) , Q->alpha) * g;
n0 = sqrt(1. - P->es) / (1. - P->es * pow(sin(P->phi0), 2));
Q->n = sin(S0);
Q->rho0 = P->k0 * n0 / tan(S0);
Q->ad = S90 - UQ;
P->inv = e_inverse;
P->fwd = e_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_krovak_selftest (void) {return 0;}
#else
int pj_krovak_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=krovak +ellps=GRS80"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{-3196535.2325636409, -6617878.8675514441},
{-3260035.4405521089, -6898873.6148780314},
{-3756305.3288691747, -6478142.5615715114},
{-3831703.6585019818, -6759107.1701553948},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{24.836218918719162, 59.758403933233858},
{24.836315484509566, 59.756888425730189},
{24.830447747947495, 59.758403933233858},
{24.830351182157091, 59.756888425730189},
};
return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
}
#endif
proj-4.9.3/src/pj_initcache.c 0000644 0000000 0000000 00000013144 12761101536 012750 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: init file definition cache.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2009, 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.
*****************************************************************************/
#include
#include
static int cache_count = 0;
static int cache_alloc = 0;
static char **cache_key = NULL;
static paralist **cache_paralist = NULL;
/************************************************************************/
/* pj_clone_paralist() */
/* */
/* Allocate a copy of a parameter list. */
/************************************************************************/
paralist *pj_clone_paralist( const paralist *list)
{
paralist *list_copy = NULL, *next_copy = NULL;
for( ; list != NULL; list = list->next )
{
paralist *newitem = (paralist *)
pj_malloc(sizeof(paralist) + strlen(list->param));
newitem->used = 0;
newitem->next = 0;
strcpy( newitem->param, list->param );
if( list_copy == NULL )
list_copy = newitem;
else
next_copy->next = newitem;
next_copy = newitem;
}
return list_copy;
}
/************************************************************************/
/* pj_clear_initcache() */
/* */
/* Clear out all memory held in the init file cache. */
/************************************************************************/
void pj_clear_initcache()
{
if( cache_alloc > 0 )
{
int i;
pj_acquire_lock();
for( i = 0; i < cache_count; i++ )
{
paralist *n, *t = cache_paralist[i];
pj_dalloc( cache_key[i] );
/* free parameter list elements */
for (; t != NULL; t = n) {
n = t->next;
pj_dalloc(t);
}
}
pj_dalloc( cache_key );
pj_dalloc( cache_paralist );
cache_count = 0;
cache_alloc= 0;
cache_key = NULL;
cache_paralist = NULL;
pj_release_lock();
}
}
/************************************************************************/
/* pj_search_initcache() */
/* */
/* Search for a matching definition in the init cache. */
/************************************************************************/
paralist *pj_search_initcache( const char *filekey )
{
int i;
paralist *result = NULL;
pj_acquire_lock();
for( i = 0; result == NULL && i < cache_count; i++)
{
if( strcmp(filekey,cache_key[i]) == 0 )
{
result = pj_clone_paralist( cache_paralist[i] );
}
}
pj_release_lock();
return result;
}
/************************************************************************/
/* pj_insert_initcache() */
/* */
/* Insert a paralist definition in the init file cache. */
/************************************************************************/
void pj_insert_initcache( const char *filekey, const paralist *list )
{
pj_acquire_lock();
/*
** Grow list if required.
*/
if( cache_count == cache_alloc )
{
char **cache_key_new;
paralist **cache_paralist_new;
cache_alloc = cache_alloc * 2 + 15;
cache_key_new = (char **) pj_malloc(sizeof(char*) * cache_alloc);
memcpy( cache_key_new, cache_key, sizeof(char*) * cache_count);
pj_dalloc( cache_key );
cache_key = cache_key_new;
cache_paralist_new = (paralist **)
pj_malloc(sizeof(paralist*) * cache_alloc);
memcpy( cache_paralist_new, cache_paralist,
sizeof(paralist*) * cache_count );
pj_dalloc( cache_paralist );
cache_paralist = cache_paralist_new;
}
/*
** Duplicate the filekey and paralist, and insert in cache.
*/
cache_key[cache_count] = (char *) pj_malloc(strlen(filekey)+1);
strcpy( cache_key[cache_count], filekey );
cache_paralist[cache_count] = pj_clone_paralist( list );
cache_count++;
pj_release_lock();
}
proj-4.9.3/src/pj_ell_set.c 0000644 0000000 0000000 00000006642 12761101536 012455 0000000 0000000 /* set ellipsoid parameters a and es */
#include
#include
#define SIXTH .1666666666666666667 /* 1/6 */
#define RA4 .04722222222222222222 /* 17/360 */
#define RA6 .02215608465608465608 /* 67/3024 */
#define RV4 .06944444444444444444 /* 5/72 */
#define RV6 .04243827160493827160 /* 55/1296 */
int /* initialize geographic shape parameters */
pj_ell_set(projCtx ctx, paralist *pl, double *a, double *es) {
int i;
double b=0.0, e;
char *name;
paralist *start = 0;
/* clear any previous error */
pj_ctx_set_errno(ctx,0);
/* check for varying forms of ellipsoid input */
*a = *es = 0.;
/* R takes precedence */
if (pj_param(ctx, pl, "tR").i)
*a = pj_param(ctx,pl, "dR").f;
else { /* probable elliptical figure */
/* check if ellps present and temporarily append its values to pl */
if ((name = pj_param(ctx,pl, "sellps").s) != NULL) {
char *s;
for (start = pl; start && start->next ; start = start->next) ;
for (i = 0; (s = pj_ellps[i].id) && strcmp(name, s) ; ++i) ;
if (!s) { pj_ctx_set_errno( ctx, -9); return 1; }
start->next = pj_mkparam(pj_ellps[i].major);
start->next->next = pj_mkparam(pj_ellps[i].ell);
}
*a = pj_param(ctx,pl, "da").f;
if (pj_param(ctx,pl, "tes").i) /* eccentricity squared */
*es = pj_param(ctx,pl, "des").f;
else if (pj_param(ctx,pl, "te").i) { /* eccentricity */
e = pj_param(ctx,pl, "de").f;
*es = e * e;
} else if (pj_param(ctx,pl, "trf").i) { /* recip flattening */
*es = pj_param(ctx,pl, "drf").f;
if (!*es) {
pj_ctx_set_errno( ctx, -10);
goto bomb;
}
*es = 1./ *es;
*es = *es * (2. - *es);
} else if (pj_param(ctx,pl, "tf").i) { /* flattening */
*es = pj_param(ctx,pl, "df").f;
*es = *es * (2. - *es);
} else if (pj_param(ctx,pl, "tb").i) { /* minor axis */
b = pj_param(ctx,pl, "db").f;
*es = 1. - (b * b) / (*a * *a);
} /* else *es == 0. and sphere of radius *a */
if (!b)
b = *a * sqrt(1. - *es);
/* following options turn ellipsoid into equivalent sphere */
if (pj_param(ctx,pl, "bR_A").i) { /* sphere--area of ellipsoid */
*a *= 1. - *es * (SIXTH + *es * (RA4 + *es * RA6));
*es = 0.;
} else if (pj_param(ctx,pl, "bR_V").i) { /* sphere--vol. of ellipsoid */
*a *= 1. - *es * (SIXTH + *es * (RV4 + *es * RV6));
*es = 0.;
} else if (pj_param(ctx,pl, "bR_a").i) { /* sphere--arithmetic mean */
*a = .5 * (*a + b);
*es = 0.;
} else if (pj_param(ctx,pl, "bR_g").i) { /* sphere--geometric mean */
*a = sqrt(*a * b);
*es = 0.;
} else if (pj_param(ctx,pl, "bR_h").i) { /* sphere--harmonic mean */
*a = 2. * *a * b / (*a + b);
*es = 0.;
} else if ((i = pj_param(ctx,pl, "tR_lat_a").i) || /* sphere--arith. */
pj_param(ctx,pl, "tR_lat_g").i) { /* or geom. mean at latitude */
double tmp;
tmp = sin(pj_param(ctx,pl, i ? "rR_lat_a" : "rR_lat_g").f);
if (fabs(tmp) > M_HALFPI) {
pj_ctx_set_errno(ctx,-11);
goto bomb;
}
tmp = 1. - *es * tmp * tmp;
*a *= i ? .5 * (1. - *es + tmp) / ( tmp * sqrt(tmp)) :
sqrt(1. - *es) / tmp;
*es = 0.;
}
bomb:
if (start) { /* clean up temporary extension of list */
pj_dalloc(start->next->next);
pj_dalloc(start->next);
start->next = 0;
}
if (ctx->last_errno)
return 1;
}
/* some remaining checks */
if (*es < 0.)
{ pj_ctx_set_errno( ctx, -12); return 1; }
if (*a <= 0.)
{ pj_ctx_set_errno( ctx, -13); return 1; }
return 0;
}
proj-4.9.3/src/emess.c 0000644 0000000 0000000 00000002605 12761101536 011444 0000000 0000000 /* Error message processing */
#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
#include
#include
#include
#include
#include
#include
#define EMESS_ROUTINE
#include "emess.h"
void
emess(int code, char *fmt, ...) {
va_list args;
va_start(args, fmt);
/* prefix program name, if given */
if (fmt != NULL)
(void)fprintf(stderr,"%s\n<%s>: ",pj_get_release(),
emess_dat.Prog_name);
/* print file name and line, if given */
if (emess_dat.File_name != NULL && *emess_dat.File_name) {
(void)fprintf(stderr,"while processing file: %s", emess_dat.File_name);
if (emess_dat.File_line > 0)
(void)fprintf(stderr,", line %d\n", emess_dat.File_line);
else
(void)fputc('\n', stderr);
} else
putc('\n', stderr);
/* if |code|==2, print errno code data */
if (code == 2 || code == -2)
(void)fprintf(stderr, "Sys errno: %d: %s\n",
errno,
#ifdef HAVE_STRERROR
strerror(errno));
#else
"");
#endif
/* post remainder of call data */
(void)vfprintf(stderr,fmt,args);
va_end(args);
/* die if code positive */
if (code > 0) {
(void)fputs("\nprogram abnormally terminated\n", stderr);
exit(code);
}
else
putc('\n', stderr);
}
proj-4.9.3/src/PJ_gn_sinu.c 0000644 0000000 0000000 00000021400 12761101536 012355 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(gn_sinu, "General Sinusoidal Series") "\n\tPCyl, Sph.\n\tm= n=";
PROJ_HEAD(sinu, "Sinusoidal (Sanson-Flamsteed)") "\n\tPCyl, Sph&Ell";
PROJ_HEAD(eck6, "Eckert VI") "\n\tPCyl, Sph.";
PROJ_HEAD(mbtfps, "McBryde-Thomas Flat-Polar Sinusoidal") "\n\tPCyl, Sph.";
#define EPS10 1e-10
#define MAX_ITER 8
#define LOOP_TOL 1e-7
struct pj_opaque {
double *en;
double m, n, C_x, C_y;
};
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
double s, c;
xy.y = pj_mlfn(lp.phi, s = sin(lp.phi), c = cos(lp.phi), P->opaque->en);
xy.x = lp.lam * c / sqrt(1. - P->es * s * s);
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
double s;
if ((s = fabs(lp.phi = pj_inv_mlfn(P->ctx, xy.y, P->es, P->opaque->en))) < M_HALFPI) {
s = sin(lp.phi);
lp.lam = xy.x * sqrt(1. - P->es * s * s) / cos(lp.phi);
} else if ((s - EPS10) < M_HALFPI) {
lp.lam = 0.;
} else {
I_ERROR;
}
return lp;
}
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
if (!Q->m)
lp.phi = Q->n != 1. ? aasin(P->ctx,Q->n * sin(lp.phi)): lp.phi;
else {
double k, V;
int i;
k = Q->n * sin(lp.phi);
for (i = MAX_ITER; i ; --i) {
lp.phi -= V = (Q->m * lp.phi + sin(lp.phi) - k) /
(Q->m + cos(lp.phi));
if (fabs(V) < LOOP_TOL)
break;
}
if (!i)
F_ERROR
}
xy.x = Q->C_x * lp.lam * (Q->m + cos(lp.phi));
xy.y = Q->C_y * lp.phi;
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
xy.y /= Q->C_y;
lp.phi = Q->m ? aasin(P->ctx,(Q->m * xy.y + sin(xy.y)) / Q->n) :
( Q->n != 1. ? aasin(P->ctx,sin(xy.y) / Q->n) : xy.y );
lp.lam = xy.x / (Q->C_x * (Q->m + cos(xy.y)));
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
if (P->opaque->en)
pj_dalloc(P->opaque->en);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
/* for spheres, only */
static void setup(PJ *P) {
struct pj_opaque *Q = P->opaque;
P->es = 0;
P->inv = s_inverse;
P->fwd = s_forward;
Q->C_x = (Q->C_y = sqrt((Q->m + 1.) / Q->n))/(Q->m + 1.);
}
PJ *PROJECTION(sinu) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
if (!(Q->en = pj_enfn(P->es)))
E_ERROR_0;
if (P->es) {
P->inv = e_inverse;
P->fwd = e_forward;
} else {
Q->n = 1.;
Q->m = 0.;
setup(P);
}
return P;
}
PJ *PROJECTION(eck6) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->m = 1.;
Q->n = 2.570796326794896619231321691;
setup(P);
return P;
}
PJ *PROJECTION(mbtfps) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->m = 0.5;
Q->n = 1.785398163397448309615660845;
setup(P);
return P;
}
PJ *PROJECTION(gn_sinu) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
if (pj_param(P->ctx, P->params, "tn").i && pj_param(P->ctx, P->params, "tm").i) {
Q->n = pj_param(P->ctx, P->params, "dn").f;
Q->m = pj_param(P->ctx, P->params, "dm").f;
} else
E_ERROR(-99)
setup(P);
return P;
}
#ifndef PJ_SELFTEST
int pj_sinu_selftest (void) {return 0;}
#else
int pj_sinu_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=sinu +ellps=GRS80 +lat_1=0.5 +lat_2=2"};
char s_args[] = {"+proj=sinu +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222605.29953946592, 110574.38855415257},
{ 222605.29953946592, -110574.38855415257},
{-222605.29953946592, 110574.38855415257},
{-222605.29953946592, -110574.38855415257},
};
XY s_fwd_expect[] = {
{ 223368.11902663155, 111701.07212763709},
{ 223368.11902663155, -111701.07212763709},
{-223368.11902663155, 111701.07212763709},
{-223368.11902663155, -111701.07212763709},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.0017966305684613522, 0.00090436947707945409},
{ 0.0017966305684613522, -0.00090436947707945409},
{-0.0017966305684613522, 0.00090436947707945409},
{-0.0017966305684613522, -0.00090436947707945409},
};
LP s_inv_expect[] = {
{ 0.0017904931100023887, 0.00089524655489191132},
{ 0.0017904931100023887, -0.00089524655489191132},
{-0.0017904931100023887, 0.00089524655489191132},
{-0.0017904931100023887, -0.00089524655489191132},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_eck6_selftest (void) {return 0;}
#else
int pj_eck6_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=eck6 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 197021.60562899226, 126640.42073317352},
{ 197021.60562899226, -126640.42073317352},
{-197021.60562899226, 126640.42073317352},
{-197021.60562899226, -126640.42073317352},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.002029978749734037, 0.00078963032910382171},
{ 0.002029978749734037, -0.00078963032910382171},
{-0.002029978749734037, 0.00078963032910382171},
{-0.002029978749734037, -0.00078963032910382171},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_mbtfps_selftest (void) {return 0;}
#else
int pj_mbtfps_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=mbtfps +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 204740.11747857218, 121864.72971934026},
{ 204740.11747857218, -121864.72971934026},
{-204740.11747857218, 121864.72971934026},
{-204740.11747857218, -121864.72971934026},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0019534152166442065, 0.00082057965689633387},
{ 0.0019534152166442065, -0.00082057965689633387},
{-0.0019534152166442065, 0.00082057965689633387},
{-0.0019534152166442065, -0.00082057965689633387},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_gn_sinu_selftest (void) {return 0;}
#else
int pj_gn_sinu_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=gn_sinu +a=6400000 +lat_1=0.5 +lat_2=2 +m=1 +n=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223385.13250469571, 111698.23644718733},
{ 223385.13250469571, -111698.23644718733},
{-223385.13250469571, 111698.23644718733},
{-223385.13250469571, -111698.23644718733},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0017904931098931057, 0.00089524655491012516},
{ 0.0017904931098931057, -0.00089524655491012516},
{-0.0017904931098931057, 0.00089524655491012516},
{-0.0017904931098931057, -0.00089524655491012516},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_times.c 0000644 0000000 0000000 00000007114 12761101536 012042 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Implementation of the Times projection.
* Author: Kristian Evers
*
******************************************************************************
* Copyright (c) 2016, Kristian Evers
*
* 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.
*****************************************************************************
* Based on describtion of the Times Projection in
*
* Flattening the Earth, Snyder, J.P., 1993, p.213-214.
*****************************************************************************/
#define PJ_LIB__
#include
PROJ_HEAD(times, "Times") "\n\tCyl, Sph";
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
double T, S, S2;
XY xy = {0.0,0.0};
(void) P;
T = tan(lp.phi/2.0);
S = sin(M_FORTPI * T);
S2 = S*S;
xy.x = lp.lam * (0.74482 - 0.34588*S2);
xy.y = 1.70711 * T;
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
double T, S, S2;
LP lp = {0.0,0.0};
(void) P;
T = xy.y / 1.70711;
S = sin(M_FORTPI * T);
S2 = S*S;
lp.lam = xy.x / (0.74482 - 0.34588 * S2);
lp.phi = 2 * atan(T);
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(times) {
P->es = 0.0;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_times_selftest (void) {return 0;}
#else
int pj_times_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
int result;
int n = 5;
char s_args[] = {"+proj=times +ellps=sphere"};
XY *inv_in = malloc(n*sizeof(XY));
LP *s_inv_expect = malloc(n*sizeof(LP));
LP fwd_in[] = {
{ 0, 0},
{ 80, 70},
{ 25, -10},
{-35, 20},
{-45, -30}
};
XY s_fwd_expect[] = {
{ 0.0, 0.0},
{ 5785183.5760670956, 7615452.0661204215},
{ 2065971.5301078814, -951526.0648494592},
{-2873054.0454850947, 1917730.9530005211},
{-3651383.2035214868, -2914213.4578159209},
};
memcpy(inv_in, &s_fwd_expect, n*sizeof(XY));
memcpy(s_inv_expect, &fwd_in, n*sizeof(LP));
result = pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, n, n, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
free(inv_in);
free(s_inv_expect);
return result;
}
#endif
proj-4.9.3/src/PJ_urm5.c 0000644 0000000 0000000 00000003477 12761101536 011621 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(urm5, "Urmaev V") "\n\tPCyl., Sph., no inv.\n\tn= q= alpha=";
struct pj_opaque {
double m, rmn, q3, n;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0, 0.0};
struct pj_opaque *Q = P->opaque;
double t;
t = lp.phi = aasin (P->ctx, Q->n * sin (lp.phi));
xy.x = Q->m * lp.lam * cos (lp.phi);
t *= t;
xy.y = lp.phi * (1. + t * Q->q3) * Q->rmn;
return xy;
}
static void *freeup_new (PJ *P) { /* Destructor */
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(urm5) {
double alpha, t;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->n = pj_param(P->ctx, P->params, "dn").f;
Q->q3 = pj_param(P->ctx, P->params, "dq").f / 3.;
alpha = pj_param(P->ctx, P->params, "ralpha").f;
t = Q->n * sin (alpha);
Q->m = cos (alpha) / sqrt (1. - t * t);
Q->rmn = 1. / (Q->m * Q->n);
P->es = 0.;
P->inv = 0;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_urm5_selftest (void) {return 0;}
#else
int pj_urm5_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=urm5 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223393.6384339639, 111696.81878511712},
{ 223393.6384339639, -111696.81878511712},
{-223393.6384339639, 111696.81878511712},
{-223393.6384339639, -111696.81878511712},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/geod_interface.c 0000644 0000000 0000000 00000001712 12761101536 013264 0000000 0000000 #include "projects.h"
#include "geod_interface.h"
void geod_ini(void) {
geod_init(&GlobalGeodesic, geod_a, geod_f);
}
void geod_pre(void) {
double
lat1 = phi1 / DEG_TO_RAD, lon1 = lam1 / DEG_TO_RAD,
azi1 = al12 / DEG_TO_RAD;
geod_lineinit(&GlobalGeodesicLine, &GlobalGeodesic, lat1, lon1, azi1, 0U);
}
void geod_for(void) {
double
s12 = geod_S, lat2, lon2, azi2;
geod_position(&GlobalGeodesicLine, s12, &lat2, &lon2, &azi2);
azi2 += azi2 >= 0 ? -180 : 180; /* Compute back azimuth */
phi2 = lat2 * DEG_TO_RAD;
lam2 = lon2 * DEG_TO_RAD;
al21 = azi2 * DEG_TO_RAD;
}
void geod_inv(void) {
double
lat1 = phi1 / DEG_TO_RAD, lon1 = lam1 / DEG_TO_RAD,
lat2 = phi2 / DEG_TO_RAD, lon2 = lam2 / DEG_TO_RAD,
azi1, azi2, s12;
geod_inverse(&GlobalGeodesic, lat1, lon1, lat2, lon2, &s12, &azi1, &azi2);
azi2 += azi2 >= 0 ? -180 : 180; /* Compute back azimuth */
al12 = azi1 * DEG_TO_RAD; al21 = azi2 * DEG_TO_RAD; geod_S = s12;
}
proj-4.9.3/src/PJ_collg.c 0000644 0000000 0000000 00000004265 12761101536 012025 0000000 0000000 #define PJ_LIB__
# include
PROJ_HEAD(collg, "Collignon") "\n\tPCyl, Sph.";
#define FXC 1.12837916709551257390
#define FYC 1.77245385090551602729
#define ONEEPS 1.0000001
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
(void) P;
if ((xy.y = 1. - sin(lp.phi)) <= 0.)
xy.y = 0.;
else
xy.y = sqrt(xy.y);
xy.x = FXC * lp.lam * xy.y;
xy.y = FYC * (1. - xy.y);
return (xy);
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
lp.phi = xy.y / FYC - 1.;
if (fabs(lp.phi = 1. - lp.phi * lp.phi) < 1.)
lp.phi = asin(lp.phi);
else if (fabs(lp.phi) > ONEEPS) I_ERROR
else lp.phi = lp.phi < 0. ? -M_HALFPI : M_HALFPI;
if ((lp.lam = 1. - sin(lp.phi)) <= 0.)
lp.lam = 0.;
else
lp.lam = xy.x / (FXC * sqrt(lp.lam));
return (lp);
}
static void *freeup_new (PJ *P) { /* Destructor */
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(collg) {
P->es = 0.0;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_collg_selftest (void) {return 0;}
#else
int pj_collg_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=collg +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{249872.921577929839, 99423.1747884602082},
{254272.532301245432, -98559.3077607425657},
{-249872.921577929839, 99423.1747884602082},
{-254272.532301245432, -98559.3077607425657},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{0.00158679719207879865, 0.00101017310941749921},
{0.001586769215623956, -0.00101018201458258111},
{-0.00158679719207879865, 0.00101017310941749921},
{-0.001586769215623956, -0.00101018201458258111},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_gins8.c 0000644 0000000 0000000 00000002701 12761101536 011746 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(gins8, "Ginsburg VIII (TsNIIGAiK)") "\n\tPCyl, Sph., no inv.";
#define Cl 0.000952426
#define Cp 0.162388
#define C12 0.08333333333333333
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
double t = lp.phi * lp.phi;
(void) P;
xy.y = lp.phi * (1. + t * C12);
xy.x = lp.lam * (1. - Cp * t);
t = lp.lam * lp.lam;
xy.x *= (0.87 - Cl * t * t);
return xy;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(gins8) {
P->es = 0.0;
P->inv = 0;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_gins8_selftest (void) {return 0;}
#else
int pj_gins8_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=gins8 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 194350.25093959007, 111703.90763533533},
{ 194350.25093959007, -111703.90763533533},
{-194350.25093959007, 111703.90763533533},
{-194350.25093959007, -111703.90763533533},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/Makefile.in 0000644 0000000 0000000 00000126425 12761101666 012244 0000000 0000000 # Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = proj$(EXEEXT) nad2bin$(EXEEXT) geod$(EXEEXT) \
cs2cs$(EXEEXT)
EXTRA_PROGRAMS = multistresstest$(EXEEXT) test228$(EXEEXT)
subdir = src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(include_HEADERS) \
$(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = proj_config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
test -z "$$files" \
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
"$(DESTDIR)$(includedir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
libproj_la_LIBADD =
am_libproj_la_OBJECTS = PJ_aeqd.lo PJ_gnom.lo PJ_laea.lo \
PJ_mod_ster.lo PJ_nsper.lo PJ_nzmg.lo PJ_ortho.lo PJ_stere.lo \
PJ_sterea.lo PJ_aea.lo PJ_bipc.lo PJ_bonne.lo PJ_eqdc.lo \
PJ_isea.lo PJ_imw_p.lo PJ_krovak.lo PJ_lcc.lo PJ_poly.lo \
PJ_rpoly.lo PJ_sconics.lo proj_rouss.lo PJ_cass.lo PJ_cc.lo \
PJ_cea.lo PJ_eqc.lo PJ_gall.lo PJ_labrd.lo PJ_lsat.lo \
PJ_misrsom.lo PJ_merc.lo PJ_mill.lo PJ_ocea.lo PJ_omerc.lo \
PJ_somerc.lo PJ_tcc.lo PJ_tcea.lo PJ_times.lo PJ_tmerc.lo \
PJ_airy.lo PJ_aitoff.lo PJ_august.lo PJ_bacon.lo PJ_chamb.lo \
PJ_hammer.lo PJ_lagrng.lo PJ_larr.lo PJ_lask.lo PJ_nocol.lo \
PJ_ob_tran.lo PJ_oea.lo PJ_tpeqd.lo PJ_vandg.lo PJ_vandg2.lo \
PJ_vandg4.lo PJ_wag7.lo PJ_lcca.lo PJ_geos.lo proj_etmerc.lo \
PJ_boggs.lo PJ_collg.lo PJ_comill.lo PJ_crast.lo PJ_denoy.lo \
PJ_eck1.lo PJ_eck2.lo PJ_eck3.lo PJ_eck4.lo PJ_eck5.lo \
PJ_fahey.lo PJ_fouc_s.lo PJ_gins8.lo PJ_gstmerc.lo \
PJ_gn_sinu.lo PJ_goode.lo PJ_igh.lo PJ_hatano.lo PJ_loxim.lo \
PJ_mbt_fps.lo PJ_mbtfpp.lo PJ_mbtfpq.lo PJ_moll.lo PJ_nell.lo \
PJ_nell_h.lo PJ_patterson.lo PJ_putp2.lo PJ_putp3.lo \
PJ_putp4p.lo PJ_putp5.lo PJ_putp6.lo PJ_qsc.lo PJ_robin.lo \
PJ_sch.lo PJ_sts.lo PJ_urm5.lo PJ_urmfps.lo PJ_wag2.lo \
PJ_wag3.lo PJ_wink1.lo PJ_wink2.lo pj_latlong.lo pj_geocent.lo \
aasincos.lo adjlon.lo bch2bps.lo bchgen.lo biveval.lo \
dmstor.lo mk_cheby.lo pj_auth.lo pj_deriv.lo pj_ell_set.lo \
pj_ellps.lo pj_errno.lo pj_factors.lo pj_fwd.lo pj_init.lo \
pj_inv.lo pj_fwd3d.lo pj_inv3d.lo pj_list.lo pj_malloc.lo \
pj_mlfn.lo pj_msfn.lo proj_mdist.lo pj_open_lib.lo pj_param.lo \
pj_phi2.lo pj_pr_list.lo pj_qsfn.lo pj_generic_selftest.lo \
pj_run_selftests.lo pj_strerrno.lo pj_tsfn.lo pj_units.lo \
pj_ctx.lo pj_log.lo pj_zpoly1.lo rtodms.lo vector1.lo \
pj_release.lo pj_gauss.lo PJ_healpix.lo PJ_natearth.lo \
PJ_natearth2.lo PJ_calcofi.lo pj_fileapi.lo pj_gc_reader.lo \
pj_gridcatalog.lo nad_cvt.lo nad_init.lo nad_intr.lo emess.lo \
pj_apply_gridshift.lo pj_datums.lo pj_datum_set.lo \
pj_transform.lo geocent.lo pj_utils.lo pj_gridinfo.lo \
pj_gridlist.lo jniproj.lo pj_mutex.lo pj_initcache.lo \
pj_apply_vgridshift.lo geodesic.lo pj_strtod.lo
libproj_la_OBJECTS = $(am_libproj_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
libproj_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(libproj_la_LDFLAGS) $(LDFLAGS) -o $@
PROGRAMS = $(bin_PROGRAMS)
am_cs2cs_OBJECTS = cs2cs.$(OBJEXT) gen_cheb.$(OBJEXT) \
p_series.$(OBJEXT)
cs2cs_OBJECTS = $(am_cs2cs_OBJECTS)
cs2cs_DEPENDENCIES = libproj.la
am_geod_OBJECTS = geod.$(OBJEXT) geod_set.$(OBJEXT) \
geod_interface.$(OBJEXT)
geod_OBJECTS = $(am_geod_OBJECTS)
geod_DEPENDENCIES = libproj.la
am_multistresstest_OBJECTS = multistresstest.$(OBJEXT)
multistresstest_OBJECTS = $(am_multistresstest_OBJECTS)
multistresstest_DEPENDENCIES = libproj.la
am_nad2bin_OBJECTS = nad2bin.$(OBJEXT)
nad2bin_OBJECTS = $(am_nad2bin_OBJECTS)
nad2bin_DEPENDENCIES = libproj.la
am_proj_OBJECTS = proj.$(OBJEXT) gen_cheb.$(OBJEXT) p_series.$(OBJEXT)
proj_OBJECTS = $(am_proj_OBJECTS)
proj_DEPENDENCIES = libproj.la
am_test228_OBJECTS = test228.$(OBJEXT)
test228_OBJECTS = $(am_test228_OBJECTS)
test228_DEPENDENCIES = libproj.la
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libproj_la_SOURCES) $(cs2cs_SOURCES) $(geod_SOURCES) \
$(multistresstest_SOURCES) $(nad2bin_SOURCES) $(proj_SOURCES) \
$(test228_SOURCES)
DIST_SOURCES = $(libproj_la_SOURCES) $(cs2cs_SOURCES) $(geod_SOURCES) \
$(multistresstest_SOURCES) $(nad2bin_SOURCES) $(proj_SOURCES) \
$(test228_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
HEADERS = $(include_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
$(LISP)proj_config.h.in
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/proj_config.h.in \
$(top_srcdir)/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
C_WFLAGS = @C_WFLAGS@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
JNI_INCLUDE = @JNI_INCLUDE@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MUTEX_SETTING = @MUTEX_SETTING@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
THREAD_LIB = @THREAD_LIB@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CFLAGS = @C_WFLAGS@
AM_CPPFLAGS = -DPROJ_LIB=\"$(pkgdatadir)\" \
-DMUTEX_@MUTEX_SETTING@ @JNI_INCLUDE@
include_HEADERS = proj_api.h projects.h geodesic.h \
org_proj4_Projections.h org_proj4_PJ.h
EXTRA_DIST = makefile.vc proj.def bin_cs2cs.cmake \
bin_geod.cmake bin_nad2bin.cmake bin_proj.cmake \
lib_proj.cmake CMakeLists.txt bin_geodtest.cmake geodtest.c
proj_SOURCES = proj.c gen_cheb.c p_series.c
cs2cs_SOURCES = cs2cs.c gen_cheb.c p_series.c
nad2bin_SOURCES = nad2bin.c
geod_SOURCES = geod.c geod_set.c geod_interface.c geod_interface.h
multistresstest_SOURCES = multistresstest.c
test228_SOURCES = test228.c
proj_LDADD = libproj.la
cs2cs_LDADD = libproj.la
nad2bin_LDADD = libproj.la
geod_LDADD = libproj.la
multistresstest_LDADD = libproj.la @THREAD_LIB@
test228_LDADD = libproj.la @THREAD_LIB@
lib_LTLIBRARIES = libproj.la
libproj_la_LDFLAGS = -no-undefined -version-info 12:0:0
libproj_la_SOURCES = \
pj_list.h \
PJ_aeqd.c PJ_gnom.c PJ_laea.c PJ_mod_ster.c \
PJ_nsper.c PJ_nzmg.c PJ_ortho.c PJ_stere.c PJ_sterea.c \
PJ_aea.c PJ_bipc.c PJ_bonne.c PJ_eqdc.c PJ_isea.c \
PJ_imw_p.c PJ_krovak.c PJ_lcc.c PJ_poly.c \
PJ_rpoly.c PJ_sconics.c proj_rouss.c \
PJ_cass.c PJ_cc.c PJ_cea.c PJ_eqc.c \
PJ_gall.c PJ_labrd.c PJ_lsat.c PJ_misrsom.c PJ_merc.c \
PJ_mill.c PJ_ocea.c PJ_omerc.c PJ_somerc.c \
PJ_tcc.c PJ_tcea.c PJ_times.c PJ_tmerc.c \
PJ_airy.c PJ_aitoff.c PJ_august.c PJ_bacon.c \
PJ_chamb.c PJ_hammer.c PJ_lagrng.c PJ_larr.c \
PJ_lask.c PJ_nocol.c PJ_ob_tran.c PJ_oea.c \
PJ_tpeqd.c PJ_vandg.c PJ_vandg2.c PJ_vandg4.c \
PJ_wag7.c PJ_lcca.c PJ_geos.c proj_etmerc.c \
PJ_boggs.c PJ_collg.c PJ_comill.c PJ_crast.c PJ_denoy.c \
PJ_eck1.c PJ_eck2.c PJ_eck3.c PJ_eck4.c \
PJ_eck5.c PJ_fahey.c PJ_fouc_s.c PJ_gins8.c PJ_gstmerc.c \
PJ_gn_sinu.c PJ_goode.c PJ_igh.c PJ_hatano.c PJ_loxim.c \
PJ_mbt_fps.c PJ_mbtfpp.c PJ_mbtfpq.c PJ_moll.c \
PJ_nell.c PJ_nell_h.c PJ_patterson.c PJ_putp2.c PJ_putp3.c \
PJ_putp4p.c PJ_putp5.c PJ_putp6.c PJ_qsc.c PJ_robin.c \
PJ_sch.c PJ_sts.c PJ_urm5.c PJ_urmfps.c PJ_wag2.c \
PJ_wag3.c PJ_wink1.c PJ_wink2.c pj_latlong.c pj_geocent.c \
aasincos.c adjlon.c bch2bps.c bchgen.c \
biveval.c dmstor.c mk_cheby.c pj_auth.c \
pj_deriv.c pj_ell_set.c pj_ellps.c pj_errno.c \
pj_factors.c pj_fwd.c pj_init.c pj_inv.c pj_fwd3d.c pj_inv3d.c\
pj_list.c pj_malloc.c pj_mlfn.c pj_msfn.c proj_mdist.c \
pj_open_lib.c pj_param.c pj_phi2.c pj_pr_list.c \
pj_qsfn.c pj_generic_selftest.c pj_run_selftests.c pj_strerrno.c \
pj_tsfn.c pj_units.c pj_ctx.c pj_log.c pj_zpoly1.c rtodms.c \
vector1.c pj_release.c pj_gauss.c \
PJ_healpix.c PJ_natearth.c PJ_natearth2.c PJ_calcofi.c pj_fileapi.c \
\
pj_gc_reader.c pj_gridcatalog.c \
nad_cvt.c nad_init.c nad_intr.c emess.c emess.h \
pj_apply_gridshift.c pj_datums.c pj_datum_set.c pj_transform.c \
geocent.c geocent.h pj_utils.c pj_gridinfo.c pj_gridlist.c \
jniproj.c pj_mutex.c pj_initcache.c pj_apply_vgridshift.c geodesic.c \
pj_strtod.c
all: proj_config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu src/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
proj_config.h: stamp-h1
@test -f $@ || rm -f stamp-h1
@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
stamp-h1: $(srcdir)/proj_config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status src/proj_config.h
$(srcdir)/proj_config.h.in: $(am__configure_deps)
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f proj_config.h stamp-h1
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
list2="$$list2 $$p"; \
else :; fi; \
done; \
test -z "$$list2" || { \
echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
}
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
for p in $$list; do \
$(am__strip_dir) \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
done
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
libproj.la: $(libproj_la_OBJECTS) $(libproj_la_DEPENDENCIES) $(EXTRA_libproj_la_DEPENDENCIES)
$(AM_V_CCLD)$(libproj_la_LINK) -rpath $(libdir) $(libproj_la_OBJECTS) $(libproj_la_LIBADD) $(LIBS)
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p \
|| test -f $$p1 \
; then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' \
-e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) files[d] = files[d] " " $$1; \
else { print "f", $$3 "/" $$4, $$1; } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
} \
; done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' \
`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(bindir)" && rm -f $$files
clean-binPROGRAMS:
@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
cs2cs$(EXEEXT): $(cs2cs_OBJECTS) $(cs2cs_DEPENDENCIES) $(EXTRA_cs2cs_DEPENDENCIES)
@rm -f cs2cs$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(cs2cs_OBJECTS) $(cs2cs_LDADD) $(LIBS)
geod$(EXEEXT): $(geod_OBJECTS) $(geod_DEPENDENCIES) $(EXTRA_geod_DEPENDENCIES)
@rm -f geod$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(geod_OBJECTS) $(geod_LDADD) $(LIBS)
multistresstest$(EXEEXT): $(multistresstest_OBJECTS) $(multistresstest_DEPENDENCIES) $(EXTRA_multistresstest_DEPENDENCIES)
@rm -f multistresstest$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(multistresstest_OBJECTS) $(multistresstest_LDADD) $(LIBS)
nad2bin$(EXEEXT): $(nad2bin_OBJECTS) $(nad2bin_DEPENDENCIES) $(EXTRA_nad2bin_DEPENDENCIES)
@rm -f nad2bin$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(nad2bin_OBJECTS) $(nad2bin_LDADD) $(LIBS)
proj$(EXEEXT): $(proj_OBJECTS) $(proj_DEPENDENCIES) $(EXTRA_proj_DEPENDENCIES)
@rm -f proj$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(proj_OBJECTS) $(proj_LDADD) $(LIBS)
test228$(EXEEXT): $(test228_OBJECTS) $(test228_DEPENDENCIES) $(EXTRA_test228_DEPENDENCIES)
@rm -f test228$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(test228_OBJECTS) $(test228_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_aea.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_aeqd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_airy.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_aitoff.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_august.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_bacon.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_bipc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_boggs.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_bonne.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_calcofi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_cass.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_cc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_cea.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_chamb.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_collg.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_comill.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_crast.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_denoy.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_eck1.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_eck2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_eck3.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_eck4.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_eck5.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_eqc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_eqdc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_fahey.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_fouc_s.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_gall.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_geos.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_gins8.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_gn_sinu.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_gnom.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_goode.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_gstmerc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_hammer.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_hatano.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_healpix.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_igh.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_imw_p.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_isea.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_krovak.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_labrd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_laea.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_lagrng.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_larr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_lask.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_lcc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_lcca.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_loxim.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_lsat.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_mbt_fps.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_mbtfpp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_mbtfpq.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_merc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_mill.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_misrsom.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_mod_ster.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_moll.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_natearth.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_natearth2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_nell.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_nell_h.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_nocol.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_nsper.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_nzmg.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_ob_tran.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_ocea.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_oea.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_omerc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_ortho.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_patterson.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_poly.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_putp2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_putp3.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_putp4p.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_putp5.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_putp6.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_qsc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_robin.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_rpoly.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_sch.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_sconics.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_somerc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_stere.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_sterea.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_sts.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_tcc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_tcea.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_times.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_tmerc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_tpeqd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_urm5.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_urmfps.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_vandg.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_vandg2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_vandg4.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_wag2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_wag3.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_wag7.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_wink1.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PJ_wink2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aasincos.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adjlon.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bch2bps.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bchgen.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/biveval.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cs2cs.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dmstor.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emess.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_cheb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/geocent.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/geod.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/geod_interface.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/geod_set.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/geodesic.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jniproj.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mk_cheby.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multistresstest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nad2bin.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nad_cvt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nad_init.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nad_intr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/p_series.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_apply_gridshift.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_apply_vgridshift.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_auth.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_ctx.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_datum_set.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_datums.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_deriv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_ell_set.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_ellps.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_errno.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_factors.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_fileapi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_fwd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_fwd3d.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_gauss.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_gc_reader.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_generic_selftest.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_geocent.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_gridcatalog.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_gridinfo.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_gridlist.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_init.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_initcache.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_inv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_inv3d.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_latlong.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_list.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_log.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_malloc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_mlfn.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_msfn.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_mutex.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_open_lib.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_param.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_phi2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_pr_list.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_qsfn.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_release.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_run_selftests.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_strerrno.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_strtod.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_transform.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_tsfn.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_units.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_utils.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_zpoly1.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proj.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proj_etmerc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proj_mdist.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proj_rouss.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rtodms.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test228.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vector1.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \
$(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \
$(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \
done
uninstall-includeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) proj_config.h
install-binPROGRAMS: install-libLTLIBRARIES
installdirs:
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
clean-libtool mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-includeHEADERS
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-binPROGRAMS install-exec-local \
install-libLTLIBRARIES
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \
uninstall-libLTLIBRARIES
.MAKE: all install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
clean-libtool cscopelist-am ctags ctags-am distclean \
distclean-compile distclean-generic distclean-hdr \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-exec-local install-html \
install-html-am install-includeHEADERS install-info \
install-info-am install-libLTLIBRARIES install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \
uninstall-includeHEADERS uninstall-libLTLIBRARIES
.PRECIOUS: Makefile
install-exec-local:
rm -f $(DESTDIR)$(bindir)/invproj$(EXEEXT)
(cd $(DESTDIR)$(bindir); ln -s proj$(EXEEXT) invproj$(EXEEXT))
rm -f $(DESTDIR)$(bindir)/invgeod$(EXEEXT)
(cd $(DESTDIR)$(bindir); ln -s geod$(EXEEXT) invgeod$(EXEEXT))
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
proj-4.9.3/src/PJ_larr.c 0000644 0000000 0000000 00000002521 12761101536 011656 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(larr, "Larrivee") "\n\tMisc Sph, no inv.";
#define SIXTH .16666666666666666
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
(void) P;
xy.x = 0.5 * lp.lam * (1. + sqrt(cos(lp.phi)));
xy.y = lp.phi / (cos(0.5 * lp.phi) * cos(SIXTH * lp.lam));
return xy;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(larr) {
P->es = 0;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_larr_selftest (void) {return 0;}
#else
int pj_larr_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=larr +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{223393.637624200899, 111707.215961255497},
{223393.637624200899, -111707.215961255497},
{-223393.637624200899, 111707.215961255497},
{-223393.637624200899, -111707.215961255497},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/proj_rouss.c 0000644 0000000 0000000 00000014111 12761101536 012530 0000000 0000000 /*
** libproj -- library of cartographic projections
**
** Copyright (c) 2003, 2006 Gerald I. Evenden
*/
/*
** 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.
*/
#define PJ_LIB__
#include
struct pj_opaque {
double s0;
double A1, A2, A3, A4, A5, A6;
double B1, B2, B3, B4, B5, B6, B7, B8;
double C1, C2, C3, C4, C5, C6, C7, C8;
double D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11;
void *en;
};
PROJ_HEAD(rouss, "Roussilhe Stereographic") "\n\tAzi., Ellps.";
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double s, al, cp, sp, al2, s2;
cp = cos(lp.phi);
sp = sin(lp.phi);
s = proj_mdist(lp.phi, sp, cp, Q->en) - Q->s0;
s2 = s * s;
al = lp.lam * cp / sqrt(1. - P->es * sp * sp);
al2 = al * al;
xy.x = P->k0 * al*(1.+s2*(Q->A1+s2*Q->A4)-al2*(Q->A2+s*Q->A3+s2*Q->A5
+al2*Q->A6));
xy.y = P->k0 * (al2*(Q->B1+al2*Q->B4)+
s*(1.+al2*(Q->B3-al2*Q->B6)+s2*(Q->B2+s2*Q->B8)+
s*al2*(Q->B5+s*Q->B7)));
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double s, al, x = xy.x / P->k0, y = xy.y / P->k0, x2, y2;;
x2 = x * x;
y2 = y * y;
al = x*(1.-Q->C1*y2+x2*(Q->C2+Q->C3*y-Q->C4*x2+Q->C5*y2-Q->C7*x2*y)
+y2*(Q->C6*y2-Q->C8*x2*y));
s = Q->s0 + y*(1.+y2*(-Q->D2+Q->D8*y2))+
x2*(-Q->D1+y*(-Q->D3+y*(-Q->D5+y*(-Q->D7+y*Q->D11)))+
x2*(Q->D4+y*(Q->D6+y*Q->D10)-x2*Q->D9));
lp.phi=proj_inv_mdist(P->ctx, s, Q->en);
s = sin(lp.phi);
lp.lam=al * sqrt(1. - P->es * s * s)/cos(lp.phi);
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
if (P->opaque->en)
pj_dealloc (P->opaque->en);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(rouss) {
double N0, es2, t, t2, R_R0_2, R_R0_4;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
if (!((Q->en = proj_mdist_ini(P->es))))
E_ERROR_0;
es2 = sin(P->phi0);
Q->s0 = proj_mdist(P->phi0, es2, cos(P->phi0), Q->en);
t = 1. - (es2 = P->es * es2 * es2);
N0 = 1./sqrt(t);
R_R0_2 = t * t / P->one_es;
R_R0_4 = R_R0_2 * R_R0_2;
t = tan(P->phi0);
t2 = t * t;
Q->C1 = Q->A1 = R_R0_2 / 4.;
Q->C2 = Q->A2 = R_R0_2 * (2 * t2 - 1. - 2. * es2) / 12.;
Q->A3 = R_R0_2 * t * (1. + 4. * t2)/ ( 12. * N0);
Q->A4 = R_R0_4 / 24.;
Q->A5 = R_R0_4 * ( -1. + t2 * (11. + 12. * t2))/24.;
Q->A6 = R_R0_4 * ( -2. + t2 * (11. - 2. * t2))/240.;
Q->B1 = t / (2. * N0);
Q->B2 = R_R0_2 / 12.;
Q->B3 = R_R0_2 * (1. + 2. * t2 - 2. * es2)/4.;
Q->B4 = R_R0_2 * t * (2. - t2)/(24. * N0);
Q->B5 = R_R0_2 * t * (5. + 4.* t2)/(8. * N0);
Q->B6 = R_R0_4 * (-2. + t2 * (-5. + 6. * t2))/48.;
Q->B7 = R_R0_4 * (5. + t2 * (19. + 12. * t2))/24.;
Q->B8 = R_R0_4 / 120.;
Q->C3 = R_R0_2 * t * (1. + t2)/(3. * N0);
Q->C4 = R_R0_4 * (-3. + t2 * (34. + 22. * t2))/240.;
Q->C5 = R_R0_4 * (4. + t2 * (13. + 12. * t2))/24.;
Q->C6 = R_R0_4 / 16.;
Q->C7 = R_R0_4 * t * (11. + t2 * (33. + t2 * 16.))/(48. * N0);
Q->C8 = R_R0_4 * t * (1. + t2 * 4.)/(36. * N0);
Q->D1 = t / (2. * N0);
Q->D2 = R_R0_2 / 12.;
Q->D3 = R_R0_2 * (2 * t2 + 1. - 2. * es2) / 4.;
Q->D4 = R_R0_2 * t * (1. + t2)/(8. * N0);
Q->D5 = R_R0_2 * t * (1. + t2 * 2.)/(4. * N0);
Q->D6 = R_R0_4 * (1. + t2 * (6. + t2 * 6.))/16.;
Q->D7 = R_R0_4 * t2 * (3. + t2 * 4.)/8.;
Q->D8 = R_R0_4 / 80.;
Q->D9 = R_R0_4 * t * (-21. + t2 * (178. - t2 * 26.))/720.;
Q->D10 = R_R0_4 * t * (29. + t2 * (86. + t2 * 48.))/(96. * N0);
Q->D11 = R_R0_4 * t * (37. + t2 * 44.)/(96. * N0);
P->fwd = e_forward;
P->inv = e_inverse;
return P;
}
#ifndef PJ_SELFTEST
int pj_rouss_selftest (void) {return 0;}
#else
int pj_rouss_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=rouss +ellps=GRS80 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222644.89413161727, 110611.09186837047},
{ 222644.89413161727, -110611.09186837047},
{-222644.89413161727, 110611.09186837047},
{-222644.89413161727, -110611.09186837047},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.0017966305682019911, 0.00090436947683699559},
{ 0.0017966305682019911, -0.00090436947683699559},
{-0.0017966305682019911, 0.00090436947683699559},
{-0.0017966305682019911, -0.00090436947683699559},
};
return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
}
#endif
proj-4.9.3/src/geocent.c 0000644 0000000 0000000 00000035113 12761101536 011754 0000000 0000000 /***************************************************************************/
/* RSC IDENTIFIER: GEOCENTRIC
*
* ABSTRACT
*
* This component provides conversions between Geodetic coordinates (latitude,
* longitude in radians and height in meters) and Geocentric coordinates
* (X, Y, Z) in meters.
*
* ERROR HANDLING
*
* This component checks parameters for valid values. If an invalid value
* is found, the error code is combined with the current error code using
* the bitwise or. This combining allows multiple error codes to be
* returned. The possible error codes are:
*
* GEOCENT_NO_ERROR : No errors occurred in function
* GEOCENT_LAT_ERROR : Latitude out of valid range
* (-90 to 90 degrees)
* GEOCENT_LON_ERROR : Longitude out of valid range
* (-180 to 360 degrees)
* GEOCENT_A_ERROR : Semi-major axis lessthan or equal to zero
* GEOCENT_B_ERROR : Semi-minor axis lessthan or equal to zero
* GEOCENT_A_LESS_B_ERROR : Semi-major axis less than semi-minor axis
*
*
* REUSE NOTES
*
* GEOCENTRIC is intended for reuse by any application that performs
* coordinate conversions between geodetic coordinates and geocentric
* coordinates.
*
*
* REFERENCES
*
* An Improved Algorithm for Geocentric to Geodetic Coordinate Conversion,
* Ralph Toms, February 1996 UCRL-JC-123138.
*
* Further information on GEOCENTRIC can be found in the Reuse Manual.
*
* GEOCENTRIC originated from : U.S. Army Topographic Engineering Center
* Geospatial Information Division
* 7701 Telegraph Road
* Alexandria, VA 22310-3864
*
* LICENSES
*
* None apply to this component.
*
* RESTRICTIONS
*
* GEOCENTRIC has no restrictions.
*
* ENVIRONMENT
*
* GEOCENTRIC was tested and certified in the following environments:
*
* 1. Solaris 2.5 with GCC version 2.8.1
* 2. Windows 95 with MS Visual C++ version 6
*
* MODIFICATIONS
*
* Date Description
* ---- -----------
* 25-02-97 Original Code
*
*/
/***************************************************************************/
/*
* INCLUDES
*/
#include
#include "geocent.h"
/*
* math.h - is needed for calls to sin, cos, tan and sqrt.
* geocent.h - is needed for Error codes and prototype error checking.
*/
/***************************************************************************/
/*
* DEFINES
*/
#define PI 3.14159265358979323e0
#define PI_OVER_2 (PI / 2.0e0)
#define FALSE 0
#define TRUE 1
#define COS_67P5 0.38268343236508977 /* cosine of 67.5 degrees */
#define AD_C 1.0026000 /* Toms region 1 constant */
/***************************************************************************/
/*
* FUNCTIONS
*/
long pj_Set_Geocentric_Parameters (GeocentricInfo *gi, double a, double b)
{ /* BEGIN Set_Geocentric_Parameters */
/*
* The function Set_Geocentric_Parameters receives the ellipsoid parameters
* as inputs and sets the corresponding state variables.
*
* a : Semi-major axis, in meters. (input)
* b : Semi-minor axis, in meters. (input)
*/
long Error_Code = GEOCENT_NO_ERROR;
if (a <= 0.0)
Error_Code |= GEOCENT_A_ERROR;
if (b <= 0.0)
Error_Code |= GEOCENT_B_ERROR;
if (a < b)
Error_Code |= GEOCENT_A_LESS_B_ERROR;
if (!Error_Code)
{
gi->Geocent_a = a;
gi->Geocent_b = b;
gi->Geocent_a2 = a * a;
gi->Geocent_b2 = b * b;
gi->Geocent_e2 = (gi->Geocent_a2 - gi->Geocent_b2) / gi->Geocent_a2;
gi->Geocent_ep2 = (gi->Geocent_a2 - gi->Geocent_b2) / gi->Geocent_b2;
}
return (Error_Code);
} /* END OF Set_Geocentric_Parameters */
void pj_Get_Geocentric_Parameters (GeocentricInfo *gi,
double *a,
double *b)
{ /* BEGIN Get_Geocentric_Parameters */
/*
* The function Get_Geocentric_Parameters returns the ellipsoid parameters
* to be used in geocentric coordinate conversions.
*
* a : Semi-major axis, in meters. (output)
* b : Semi-minor axis, in meters. (output)
*/
*a = gi->Geocent_a;
*b = gi->Geocent_b;
} /* END OF Get_Geocentric_Parameters */
long pj_Convert_Geodetic_To_Geocentric (GeocentricInfo *gi,
double Latitude,
double Longitude,
double Height,
double *X,
double *Y,
double *Z)
{ /* BEGIN Convert_Geodetic_To_Geocentric */
/*
* The function Convert_Geodetic_To_Geocentric converts geodetic coordinates
* (latitude, longitude, and height) to geocentric coordinates (X, Y, Z),
* according to the current ellipsoid parameters.
*
* Latitude : Geodetic latitude in radians (input)
* Longitude : Geodetic longitude in radians (input)
* Height : Geodetic height, in meters (input)
* X : Calculated Geocentric X coordinate, in meters (output)
* Y : Calculated Geocentric Y coordinate, in meters (output)
* Z : Calculated Geocentric Z coordinate, in meters (output)
*
*/
long Error_Code = GEOCENT_NO_ERROR;
double Rn; /* Earth radius at location */
double Sin_Lat; /* sin(Latitude) */
double Sin2_Lat; /* Square of sin(Latitude) */
double Cos_Lat; /* cos(Latitude) */
/*
** Don't blow up if Latitude is just a little out of the value
** range as it may just be a rounding issue. Also removed longitude
** test, it should be wrapped by cos() and sin(). NFW for PROJ.4, Sep/2001.
*/
if( Latitude < -PI_OVER_2 && Latitude > -1.001 * PI_OVER_2 )
Latitude = -PI_OVER_2;
else if( Latitude > PI_OVER_2 && Latitude < 1.001 * PI_OVER_2 )
Latitude = PI_OVER_2;
else if ((Latitude < -PI_OVER_2) || (Latitude > PI_OVER_2))
{ /* Latitude out of range */
Error_Code |= GEOCENT_LAT_ERROR;
}
if (!Error_Code)
{ /* no errors */
if (Longitude > PI)
Longitude -= (2*PI);
Sin_Lat = sin(Latitude);
Cos_Lat = cos(Latitude);
Sin2_Lat = Sin_Lat * Sin_Lat;
Rn = gi->Geocent_a / (sqrt(1.0e0 - gi->Geocent_e2 * Sin2_Lat));
*X = (Rn + Height) * Cos_Lat * cos(Longitude);
*Y = (Rn + Height) * Cos_Lat * sin(Longitude);
*Z = ((Rn * (1 - gi->Geocent_e2)) + Height) * Sin_Lat;
}
return (Error_Code);
} /* END OF Convert_Geodetic_To_Geocentric */
/*
* The function Convert_Geocentric_To_Geodetic converts geocentric
* coordinates (X, Y, Z) to geodetic coordinates (latitude, longitude,
* and height), according to the current ellipsoid parameters.
*
* X : Geocentric X coordinate, in meters. (input)
* Y : Geocentric Y coordinate, in meters. (input)
* Z : Geocentric Z coordinate, in meters. (input)
* Latitude : Calculated latitude value in radians. (output)
* Longitude : Calculated longitude value in radians. (output)
* Height : Calculated height value, in meters. (output)
*/
#define USE_ITERATIVE_METHOD
void pj_Convert_Geocentric_To_Geodetic (GeocentricInfo *gi,
double X,
double Y,
double Z,
double *Latitude,
double *Longitude,
double *Height)
{ /* BEGIN Convert_Geocentric_To_Geodetic */
#if !defined(USE_ITERATIVE_METHOD)
/*
* The method used here is derived from 'An Improved Algorithm for
* Geocentric to Geodetic Coordinate Conversion', by Ralph Toms, Feb 1996
*/
/* Note: Variable names follow the notation used in Toms, Feb 1996 */
double W; /* distance from Z axis */
double W2; /* square of distance from Z axis */
double T0; /* initial estimate of vertical component */
double T1; /* corrected estimate of vertical component */
double S0; /* initial estimate of horizontal component */
double S1; /* corrected estimate of horizontal component */
double Sin_B0; /* sin(B0), B0 is estimate of Bowring aux variable */
double Sin3_B0; /* cube of sin(B0) */
double Cos_B0; /* cos(B0) */
double Sin_p1; /* sin(phi1), phi1 is estimated latitude */
double Cos_p1; /* cos(phi1) */
double Rn; /* Earth radius at location */
double Sum; /* numerator of cos(phi1) */
int At_Pole; /* indicates location is in polar region */
At_Pole = FALSE;
if (X != 0.0)
{
*Longitude = atan2(Y,X);
}
else
{
if (Y > 0)
{
*Longitude = PI_OVER_2;
}
else if (Y < 0)
{
*Longitude = -PI_OVER_2;
}
else
{
At_Pole = TRUE;
*Longitude = 0.0;
if (Z > 0.0)
{ /* north pole */
*Latitude = PI_OVER_2;
}
else if (Z < 0.0)
{ /* south pole */
*Latitude = -PI_OVER_2;
}
else
{ /* center of earth */
*Latitude = PI_OVER_2;
*Height = -Geocent_b;
return;
}
}
}
W2 = X*X + Y*Y;
W = sqrt(W2);
T0 = Z * AD_C;
S0 = sqrt(T0 * T0 + W2);
Sin_B0 = T0 / S0;
Cos_B0 = W / S0;
Sin3_B0 = Sin_B0 * Sin_B0 * Sin_B0;
T1 = Z + gi->Geocent_b * gi->Geocent_ep2 * Sin3_B0;
Sum = W - gi->Geocent_a * gi->Geocent_e2 * Cos_B0 * Cos_B0 * Cos_B0;
S1 = sqrt(T1*T1 + Sum * Sum);
Sin_p1 = T1 / S1;
Cos_p1 = Sum / S1;
Rn = gi->Geocent_a / sqrt(1.0 - gi->Geocent_e2 * Sin_p1 * Sin_p1);
if (Cos_p1 >= COS_67P5)
{
*Height = W / Cos_p1 - Rn;
}
else if (Cos_p1 <= -COS_67P5)
{
*Height = W / -Cos_p1 - Rn;
}
else
{
*Height = Z / Sin_p1 + Rn * (gi->Geocent_e2 - 1.0);
}
if (At_Pole == FALSE)
{
*Latitude = atan(Sin_p1 / Cos_p1);
}
#else /* defined(USE_ITERATIVE_METHOD) */
/*
* Reference...
* ============
* Wenzel, H.-G.(1985): Hochauflösende Kugelfunktionsmodelle für
* das Gravitationspotential der Erde. Wiss. Arb. Univ. Hannover
* Nr. 137, p. 130-131.
* Programmed by GGA- Leibniz-Institue of Applied Geophysics
* Stilleweg 2
* D-30655 Hannover
* Federal Republic of Germany
* Internet: www.gga-hannover.de
*
* Hannover, March 1999, April 2004.
* see also: comments in statements
* remarks:
* Mathematically exact and because of symmetry of rotation-ellipsoid,
* each point (X,Y,Z) has at least two solutions (Latitude1,Longitude1,Height1) and
* (Latitude2,Longitude2,Height2). Is point=(0.,0.,Z) (P=0.), so you get even
* four solutions, every two symmetrical to the semi-minor axis.
* Here Height1 and Height2 have at least a difference in order of
* radius of curvature (e.g. (0,0,b)=> (90.,0.,0.) or (-90.,0.,-2b);
* (a+100.)*(sqrt(2.)/2.,sqrt(2.)/2.,0.) => (0.,45.,100.) or
* (0.,225.,-(2a+100.))).
* The algorithm always computes (Latitude,Longitude) with smallest |Height|.
* For normal computations, that means |Height|<10000.m, algorithm normally
* converges after to 2-3 steps!!!
* But if |Height| has the amount of length of ellipsoid's axis
* (e.g. -6300000.m), algorithm needs about 15 steps.
*/
/* local defintions and variables */
/* end-criterium of loop, accuracy of sin(Latitude) */
#define genau 1.E-12
#define genau2 (genau*genau)
#define maxiter 30
double P; /* distance between semi-minor axis and location */
double RR; /* distance between center and location */
double CT; /* sin of geocentric latitude */
double ST; /* cos of geocentric latitude */
double RX;
double RK;
double RN; /* Earth radius at location */
double CPHI0; /* cos of start or old geodetic latitude in iterations */
double SPHI0; /* sin of start or old geodetic latitude in iterations */
double CPHI; /* cos of searched geodetic latitude */
double SPHI; /* sin of searched geodetic latitude */
double SDPHI; /* end-criterium: addition-theorem of sin(Latitude(iter)-Latitude(iter-1)) */
int iter; /* # of continous iteration, max. 30 is always enough (s.a.) */
P = sqrt(X*X+Y*Y);
RR = sqrt(X*X+Y*Y+Z*Z);
/* special cases for latitude and longitude */
if (P/gi->Geocent_a < genau) {
/* special case, if P=0. (X=0., Y=0.) */
*Longitude = 0.;
/* if (X,Y,Z)=(0.,0.,0.) then Height becomes semi-minor axis
* of ellipsoid (=center of mass), Latitude becomes PI/2 */
if (RR/gi->Geocent_a < genau) {
*Latitude = PI_OVER_2;
*Height = -gi->Geocent_b;
return ;
}
}
else {
/* ellipsoidal (geodetic) longitude
* interval: -PI < Longitude <= +PI */
*Longitude=atan2(Y,X);
}
/* --------------------------------------------------------------
* Following iterative algorithm was developped by
* "Institut für Erdmessung", University of Hannover, July 1988.
* Internet: www.ife.uni-hannover.de
* Iterative computation of CPHI,SPHI and Height.
* Iteration of CPHI and SPHI to 10**-12 radian resp.
* 2*10**-7 arcsec.
* --------------------------------------------------------------
*/
CT = Z/RR;
ST = P/RR;
RX = 1.0/sqrt(1.0-gi->Geocent_e2*(2.0-gi->Geocent_e2)*ST*ST);
CPHI0 = ST*(1.0-gi->Geocent_e2)*RX;
SPHI0 = CT*RX;
iter = 0;
/* loop to find sin(Latitude) resp. Latitude
* until |sin(Latitude(iter)-Latitude(iter-1))| < genau */
do
{
iter++;
RN = gi->Geocent_a/sqrt(1.0-gi->Geocent_e2*SPHI0*SPHI0);
/* ellipsoidal (geodetic) height */
*Height = P*CPHI0+Z*SPHI0-RN*(1.0-gi->Geocent_e2*SPHI0*SPHI0);
RK = gi->Geocent_e2*RN/(RN+*Height);
RX = 1.0/sqrt(1.0-RK*(2.0-RK)*ST*ST);
CPHI = ST*(1.0-RK)*RX;
SPHI = CT*RX;
SDPHI = SPHI*CPHI0-CPHI*SPHI0;
CPHI0 = CPHI;
SPHI0 = SPHI;
}
while (SDPHI*SDPHI > genau2 && iter < maxiter);
/* ellipsoidal (geodetic) latitude */
*Latitude=atan(SPHI/fabs(CPHI));
return;
#endif /* defined(USE_ITERATIVE_METHOD) */
} /* END OF Convert_Geocentric_To_Geodetic */
proj-4.9.3/src/PJ_somerc.c 0000644 0000000 0000000 00000010652 12761101536 012212 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(somerc, "Swiss. Obl. Mercator") "\n\tCyl, Ell\n\tFor CH1903";
struct pj_opaque {
double K, c, hlf_e, kR, cosp0, sinp0;
};
#define EPS 1.e-10
#define NITER 6
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0, 0.0};
double phip, lamp, phipp, lampp, sp, cp;
struct pj_opaque *Q = P->opaque;
sp = P->e * sin (lp.phi);
phip = 2.* atan ( exp ( Q->c * (
log (tan (M_FORTPI + 0.5 * lp.phi)) - Q->hlf_e * log ((1. + sp)/(1. - sp)))
+ Q->K)) - M_HALFPI;
lamp = Q->c * lp.lam;
cp = cos(phip);
phipp = aasin (P->ctx, Q->cosp0 * sin (phip) - Q->sinp0 * cp * cos (lamp));
lampp = aasin (P->ctx, cp * sin (lamp) / cos (phipp));
xy.x = Q->kR * lampp;
xy.y = Q->kR * log (tan (M_FORTPI + 0.5 * phipp));
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double phip, lamp, phipp, lampp, cp, esp, con, delp;
int i;
phipp = 2. * (atan (exp (xy.y / Q->kR)) - M_FORTPI);
lampp = xy.x / Q->kR;
cp = cos (phipp);
phip = aasin (P->ctx, Q->cosp0 * sin (phipp) + Q->sinp0 * cp * cos (lampp));
lamp = aasin (P->ctx, cp * sin (lampp) / cos (phip));
con = (Q->K - log (tan (M_FORTPI + 0.5 * phip)))/Q->c;
for (i = NITER; i ; --i) {
esp = P->e * sin(phip);
delp = (con + log(tan(M_FORTPI + 0.5 * phip)) - Q->hlf_e *
log((1. + esp)/(1. - esp)) ) *
(1. - esp * esp) * cos(phip) * P->rone_es;
phip -= delp;
if (fabs(delp) < EPS)
break;
}
if (i) {
lp.phi = phip;
lp.lam = lamp / Q->c;
} else
I_ERROR
return (lp);
}
#if 0
FREEUP; if (P) pj_dalloc(P); }
#endif
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(somerc) {
double cp, phip0, sp;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->hlf_e = 0.5 * P->e;
cp = cos (P->phi0);
cp *= cp;
Q->c = sqrt (1 + P->es * cp * cp * P->rone_es);
sp = sin (P->phi0);
Q->cosp0 = cos( phip0 = aasin (P->ctx, Q->sinp0 = sp / Q->c) );
sp *= P->e;
Q->K = log (tan (M_FORTPI + 0.5 * phip0)) - Q->c * (
log (tan (M_FORTPI + 0.5 * P->phi0)) - Q->hlf_e *
log ((1. + sp) / (1. - sp)));
Q->kR = P->k0 * sqrt(P->one_es) / (1. - sp * sp);
P->inv = e_inverse;
P->fwd = e_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_somerc_selftest (void) {return 0;}
#else
int pj_somerc_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=somerc +ellps=GRS80 +lat_1=0.5 +lat_2=2 +n=0.5"};
char s_args[] = {"+proj=somerc +a=6400000 +lat_1=0.5 +lat_2=2 +n=0.5"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{222638.98158654713, 110579.96521824898},
{222638.98158654713, -110579.96521825089},
{-222638.98158654713, 110579.96521824898},
{-222638.98158654713, -110579.96521825089},
};
XY s_fwd_expect[] = {
{223402.14425527418, 111706.74357494408},
{223402.14425527418, -111706.74357494518},
{-223402.14425527418, 111706.74357494408},
{-223402.14425527418, -111706.74357494518},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{0.0017966305682390426, 0.00090436947704129484},
{0.0017966305682390426, -0.00090436947704377105},
{-0.0017966305682390426, 0.00090436947704129484},
{-0.0017966305682390426, -0.00090436947704377105},
};
LP s_inv_expect[] = {
{0.0017904931097838226, 0.00089524655485801927},
{0.0017904931097838226, -0.00089524655484529714},
{-0.0017904931097838226, 0.00089524655485801927},
{-0.0017904931097838226, -0.00089524655484529714},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
proj-4.9.3/src/pj_init.c 0000644 0000000 0000000 00000052762 12761101536 011775 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Initialize projection object from string definition. Includes
* pj_init(), pj_init_plus() and pj_free() function.
* Author: Gerald Evenden, Frank Warmerdam
*
******************************************************************************
* Copyright (c) 1995, Gerald Evenden
* Copyright (c) 2002, 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.
*****************************************************************************/
#define PJ_LIB__
#include
#include
#include
#include
#include
typedef struct {
projCtx ctx;
PAFile fid;
char buffer[8193];
int buffer_filled;
int at_eof;
} pj_read_state;
/************************************************************************/
/* fill_buffer() */
/************************************************************************/
static const char *fill_buffer(pj_read_state *state, const char *last_char)
{
size_t bytes_read;
size_t char_remaining, char_requested;
/* -------------------------------------------------------------------- */
/* Don't bother trying to read more if we are at eof, or if the */
/* buffer is still over half full. */
/* -------------------------------------------------------------------- */
if (last_char == NULL)
last_char = state->buffer;
if (state->at_eof)
return last_char;
char_remaining = state->buffer_filled - (last_char - state->buffer);
if (char_remaining >= sizeof(state->buffer) / 2)
return last_char;
/* -------------------------------------------------------------------- */
/* Move the existing data to the start of the buffer. */
/* -------------------------------------------------------------------- */
memmove(state->buffer, last_char, char_remaining);
state->buffer_filled = char_remaining;
last_char = state->buffer;
/* -------------------------------------------------------------------- */
/* Refill. */
/* -------------------------------------------------------------------- */
char_requested = sizeof(state->buffer) - state->buffer_filled - 1;
bytes_read = pj_ctx_fread( state->ctx, state->buffer + state->buffer_filled,
1, char_requested, state->fid );
if (bytes_read < char_requested)
{
state->at_eof = 1;
state->buffer[state->buffer_filled + bytes_read] = '\0';
}
state->buffer_filled += bytes_read;
return last_char;
}
/************************************************************************/
/* get_opt() */
/************************************************************************/
static paralist *
get_opt(projCtx ctx, paralist **start, PAFile fid, char *name, paralist *next,
int *found_def) {
pj_read_state *state = (pj_read_state*) calloc(1,sizeof(pj_read_state));
char sword[302];
int len;
int in_target = 0;
const char *next_char = NULL;
state->fid = fid;
state->ctx = ctx;
next_char = fill_buffer(state, NULL);
if(found_def)
*found_def = 0;
len = strlen(name);
*sword = 't';
/* loop till we find our target keyword */
while (*next_char)
{
next_char = fill_buffer(state, next_char);
/* Skip white space. */
while( isspace(*next_char) )
next_char++;
next_char = fill_buffer(state, next_char);
/* for comments, skip past end of line. */
if( *next_char == '#' )
{
while( *next_char && *next_char != '\n' )
next_char++;
next_char = fill_buffer(state, next_char);
if (*next_char == '\n')
next_char++;
if (*next_char == '\r')
next_char++;
}
/* Is this our target? */
else if( *next_char == '<' )
{
/* terminate processing target on the next block definition */
if (in_target)
break;
next_char++;
if (strncmp(name, next_char, len) == 0
&& next_char[len] == '>')
{
/* skip past target word */
next_char += len + 1;
in_target = 1;
if(found_def)
*found_def = 1;
}
else
{
/* skip past end of line */
while( *next_char && *next_char != '\n' )
next_char++;
}
}
else if (in_target)
{
const char *start_of_word = next_char;
int word_len = 0;
if (*start_of_word == '+')
{
start_of_word++;
next_char++;
}
/* capture parameter */
while( *next_char && !isspace(*next_char) )
{
next_char++;
word_len++;
}
strncpy(sword+1, start_of_word, word_len);
sword[word_len+1] = '\0';
/* do not override existing parameter value of same name */
if (!pj_param(ctx, *start, sword).i) {
/* don't default ellipse if datum, ellps or any earth model
information is set. */
if( strncmp(sword+1,"ellps=",6) != 0
|| (!pj_param(ctx, *start, "tdatum").i
&& !pj_param(ctx, *start, "tellps").i
&& !pj_param(ctx, *start, "ta").i
&& !pj_param(ctx, *start, "tb").i
&& !pj_param(ctx, *start, "trf").i
&& !pj_param(ctx, *start, "tf").i) )
{
next = next->next = pj_mkparam(sword+1);
}
}
}
else
{
/* skip past word */
while( *next_char && !isspace(*next_char) )
next_char++;
}
}
if (errno == 25)
errno = 0;
free(state);
return next;
}
/************************************************************************/
/* get_defaults() */
/************************************************************************/
static paralist *
get_defaults(projCtx ctx, paralist **start, paralist *next, char *name) {
PAFile fid;
if ( (fid = pj_open_lib(ctx,"proj_def.dat", "rt")) != NULL) {
next = get_opt(ctx, start, fid, "general", next, NULL);
pj_ctx_fseek(ctx, fid, 0, SEEK_SET);
next = get_opt(ctx, start, fid, name, next, NULL);
pj_ctx_fclose(ctx, fid);
}
if (errno)
errno = 0; /* don't care if can't open file */
ctx->last_errno = 0;
return next;
}
/************************************************************************/
/* get_init() */
/************************************************************************/
static paralist *
get_init(projCtx ctx, paralist **start, paralist *next, char *name,
int *found_def) {
char fname[MAX_PATH_FILENAME+ID_TAG_MAX+3], *opt;
PAFile fid;
paralist *init_items = NULL;
const paralist *orig_next = next;
(void)strncpy(fname, name, MAX_PATH_FILENAME + ID_TAG_MAX + 1);
/*
** Search for file/key pair in cache
*/
init_items = pj_search_initcache( name );
if( init_items != NULL )
{
next->next = init_items;
while( next->next != NULL )
next = next->next;
*found_def = 1;
return next;
}
/*
** Otherwise we try to open the file and search for it.
*/
if ((opt = strrchr(fname, ':')) != NULL)
*opt++ = '\0';
else { pj_ctx_set_errno(ctx,-3); return NULL; }
if ( (fid = pj_open_lib(ctx,fname, "rt")) != NULL)
next = get_opt(ctx, start, fid, opt, next, found_def);
else
return NULL;
pj_ctx_fclose(ctx, fid);
if (errno == 25)
errno = 0; /* unknown problem with some sys errno<-25 */
/*
** If we seem to have gotten a result, insert it into the
** init file cache.
*/
if( next != NULL && next != orig_next )
pj_insert_initcache( name, orig_next->next );
return next;
}
/************************************************************************/
/* pj_init_plus() */
/* */
/* Same as pj_init() except it takes one argument string with */
/* individual arguments preceeded by '+', such as "+proj=utm */
/* +zone=11 +ellps=WGS84". */
/************************************************************************/
PJ *
pj_init_plus( const char *definition )
{
return pj_init_plus_ctx( pj_get_default_ctx(), definition );
}
PJ *
pj_init_plus_ctx( projCtx ctx, const char *definition )
{
#define MAX_ARG 200
char *argv[MAX_ARG];
char *defn_copy;
int argc = 0, i, blank_count = 0;
PJ *result = NULL;
/* make a copy that we can manipulate */
defn_copy = (char *) pj_malloc( strlen(definition)+1 );
strcpy( defn_copy, definition );
/* split into arguments based on '+' and trim white space */
for( i = 0; defn_copy[i] != '\0'; i++ )
{
switch( defn_copy[i] )
{
case '+':
if( i == 0 || defn_copy[i-1] == '\0' || blank_count > 0 )
{
/* trim trailing spaces from the previous param */
if( blank_count > 0 )
{
defn_copy[i - blank_count] = '\0';
blank_count = 0;
}
if( argc+1 == MAX_ARG )
{
pj_ctx_set_errno( ctx, -44 );
goto bum_call;
}
argv[argc++] = defn_copy + i + 1;
}
break;
case ' ':
case '\t':
case '\n':
/* trim leading spaces from the current param */
if( i == 0 || defn_copy[i-1] == '\0' || argc == 0 || argv[argc-1] == defn_copy + i )
defn_copy[i] = '\0';
else
blank_count++;
break;
default:
/* reset blank_count */
blank_count = 0;
}
}
/* trim trailing spaces from the last param */
defn_copy[i - blank_count] = '\0';
/* perform actual initialization */
result = pj_init_ctx( ctx, argc, argv );
bum_call:
pj_dalloc( defn_copy );
return result;
}
/************************************************************************/
/* pj_init() */
/* */
/* Main entry point for initialing a PJ projections */
/* definition. Note that the projection specific function is */
/* called to do the initial allocation so it can be created */
/* large enough to hold projection specific parameters. */
/************************************************************************/
PJ *
pj_init(int argc, char **argv) {
return pj_init_ctx( pj_get_default_ctx(), argc, argv );
}
PJ *
pj_init_ctx(projCtx ctx, int argc, char **argv) {
char *s, *name;
paralist *start = NULL;
PJ *(*proj)(PJ *);
paralist *curr;
int i;
PJ *PIN = 0;
ctx->last_errno = 0;
start = NULL;
/* put arguments into internal linked list */
if (argc <= 0) { pj_ctx_set_errno( ctx, -1 ); goto bum_call; }
start = curr = pj_mkparam(argv[0]);
for (i = 1; i < argc; ++i) {
curr->next = pj_mkparam(argv[i]);
curr = curr->next;
}
if (ctx->last_errno) goto bum_call;
/* check if +init present */
if (pj_param(ctx, start, "tinit").i) {
int found_def = 0;
if (!(curr = get_init(ctx,&start, curr,
pj_param(ctx, start, "sinit").s,
&found_def)))
goto bum_call;
if (!found_def) { pj_ctx_set_errno( ctx, -2); goto bum_call; }
}
/* find projection selection */
if (!(name = pj_param(ctx, start, "sproj").s))
{ pj_ctx_set_errno( ctx, -4 ); goto bum_call; }
for (i = 0; (s = pj_list[i].id) && strcmp(name, s) ; ++i) ;
if (!s) { pj_ctx_set_errno( ctx, -5 ); goto bum_call; }
/* set defaults, unless inhibited */
if (!pj_param(ctx, start, "bno_defs").i)
curr = get_defaults(ctx,&start, curr, name);
proj = (PJ *(*)(PJ *)) pj_list[i].proj;
/* allocate projection structure */
if (!(PIN = (*proj)(0))) goto bum_call;
PIN->ctx = ctx;
PIN->params = start;
PIN->is_latlong = 0;
PIN->is_geocent = 0;
PIN->is_long_wrap_set = 0;
PIN->long_wrap_center = 0.0;
strcpy( PIN->axis, "enu" );
PIN->gridlist = NULL;
PIN->gridlist_count = 0;
PIN->vgridlist_geoid = NULL;
PIN->vgridlist_geoid_count = 0;
/* set datum parameters */
if (pj_datum_set(ctx, start, PIN)) goto bum_call;
/* set ellipsoid/sphere parameters */
if (pj_ell_set(ctx, start, &PIN->a, &PIN->es)) goto bum_call;
PIN->a_orig = PIN->a;
PIN->es_orig = PIN->es;
PIN->e = sqrt(PIN->es);
PIN->ra = 1. / PIN->a;
PIN->one_es = 1. - PIN->es;
if (PIN->one_es == 0.) { pj_ctx_set_errno( ctx, -6 ); goto bum_call; }
PIN->rone_es = 1./PIN->one_es;
/* Now that we have ellipse information check for WGS84 datum */
if( PIN->datum_type == PJD_3PARAM
&& PIN->datum_params[0] == 0.0
&& PIN->datum_params[1] == 0.0
&& PIN->datum_params[2] == 0.0
&& PIN->a == 6378137.0
&& ABS(PIN->es - 0.006694379990) < 0.000000000050 )/*WGS84/GRS80*/
{
PIN->datum_type = PJD_WGS84;
}
/* set PIN->geoc coordinate system */
PIN->geoc = (PIN->es && pj_param(ctx, start, "bgeoc").i);
/* over-ranging flag */
PIN->over = pj_param(ctx, start, "bover").i;
/* vertical datum geoid grids */
PIN->has_geoid_vgrids = pj_param(ctx, start, "tgeoidgrids").i;
if( PIN->has_geoid_vgrids ) /* we need to mark it as used. */
pj_param(ctx, start, "sgeoidgrids");
/* longitude center for wrapping */
PIN->is_long_wrap_set = pj_param(ctx, start, "tlon_wrap").i;
if (PIN->is_long_wrap_set)
PIN->long_wrap_center = pj_param(ctx, start, "rlon_wrap").f;
/* axis orientation */
if( (pj_param(ctx, start,"saxis").s) != NULL )
{
static const char *axis_legal = "ewnsud";
const char *axis_arg = pj_param(ctx, start,"saxis").s;
if( strlen(axis_arg) != 3 )
{
pj_ctx_set_errno( ctx, PJD_ERR_AXIS );
goto bum_call;
}
if( strchr( axis_legal, axis_arg[0] ) == NULL
|| strchr( axis_legal, axis_arg[1] ) == NULL
|| strchr( axis_legal, axis_arg[2] ) == NULL)
{
pj_ctx_set_errno( ctx, PJD_ERR_AXIS );
goto bum_call;
}
/* it would be nice to validate we don't have on axis repeated */
strcpy( PIN->axis, axis_arg );
}
PIN->is_long_wrap_set = pj_param(ctx, start, "tlon_wrap").i;
if (PIN->is_long_wrap_set)
PIN->long_wrap_center = pj_param(ctx, start, "rlon_wrap").f;
/* central meridian */
PIN->lam0=pj_param(ctx, start, "rlon_0").f;
/* central latitude */
PIN->phi0 = pj_param(ctx, start, "rlat_0").f;
/* false easting and northing */
PIN->x0 = pj_param(ctx, start, "dx_0").f;
PIN->y0 = pj_param(ctx, start, "dy_0").f;
/* general scaling factor */
if (pj_param(ctx, start, "tk_0").i)
PIN->k0 = pj_param(ctx, start, "dk_0").f;
else if (pj_param(ctx, start, "tk").i)
PIN->k0 = pj_param(ctx, start, "dk").f;
else
PIN->k0 = 1.;
if (PIN->k0 <= 0.) {
pj_ctx_set_errno( ctx, -31 );
goto bum_call;
}
/* set units */
s = 0;
if ((name = pj_param(ctx, start, "sunits").s) != NULL) {
for (i = 0; (s = pj_units[i].id) && strcmp(name, s) ; ++i) ;
if (!s) { pj_ctx_set_errno( ctx, -7 ); goto bum_call; }
s = pj_units[i].to_meter;
}
if (s || (s = pj_param(ctx, start, "sto_meter").s)) {
PIN->to_meter = pj_strtod(s, &s);
if (*s == '/') /* ratio number */
PIN->to_meter /= pj_strtod(++s, 0);
PIN->fr_meter = 1. / PIN->to_meter;
} else
PIN->to_meter = PIN->fr_meter = 1.;
/* set vertical units */
s = 0;
if ((name = pj_param(ctx, start, "svunits").s) != NULL) {
for (i = 0; (s = pj_units[i].id) && strcmp(name, s) ; ++i) ;
if (!s) { pj_ctx_set_errno( ctx, -7 ); goto bum_call; }
s = pj_units[i].to_meter;
}
if (s || (s = pj_param(ctx, start, "svto_meter").s)) {
PIN->vto_meter = pj_strtod(s, &s);
if (*s == '/') /* ratio number */
PIN->vto_meter /= pj_strtod(++s, 0);
PIN->vfr_meter = 1. / PIN->vto_meter;
} else {
PIN->vto_meter = PIN->to_meter;
PIN->vfr_meter = PIN->fr_meter;
}
/* prime meridian */
s = 0;
if ((name = pj_param(ctx, start, "spm").s) != NULL) {
const char *value = NULL;
char *next_str = NULL;
for (i = 0; pj_prime_meridians[i].id != NULL; ++i )
{
if( strcmp(name,pj_prime_meridians[i].id) == 0 )
{
value = pj_prime_meridians[i].defn;
break;
}
}
if( value == NULL
&& (dmstor_ctx(ctx,name,&next_str) != 0.0 || *name == '0')
&& *next_str == '\0' )
value = name;
if (!value) { pj_ctx_set_errno( ctx, -46 ); goto bum_call; }
PIN->from_greenwich = dmstor_ctx(ctx,value,NULL);
}
else
PIN->from_greenwich = 0.0;
/* projection specific initialization */
if (!(PIN = (*proj)(PIN)) || ctx->last_errno) {
bum_call: /* cleanup error return */
if (PIN)
pj_free(PIN);
else
for ( ; start; start = curr) {
curr = start->next;
pj_dalloc(start);
}
PIN = 0;
}
return PIN;
}
/************************************************************************/
/* pj_free() */
/* */
/* This is the application callable entry point for destroying */
/* a projection definition. It does work generic to all */
/* projection types, and then calls the projection specific */
/* free function (P->pfree()) to do local work. This maps to */
/* the FREEUP code in the individual projection source files. */
/************************************************************************/
void
pj_free(PJ *P) {
if (P) {
paralist *t, *n;
/* free parameter list elements */
for (t = P->params; t; t = n) {
n = t->next;
pj_dalloc(t);
}
/* free array of grid pointers if we have one */
if( P->gridlist != NULL )
pj_dalloc( P->gridlist );
if( P->vgridlist_geoid != NULL )
pj_dalloc( P->vgridlist_geoid );
if( P->catalog != NULL )
pj_dalloc( P->catalog );
/* free projection parameters */
P->pfree(P);
}
}
/************************************************************************/
/* pj_prepare() */
/* */
/* Helper function for the PJ_xxxx functions providing the */
/* projection specific setup for each projection type. */
/* */
/* Currently not used, but placed here as part of the material */
/* Demonstrating the idea for a future PJ_xxx architecture */
/* (cf. pj_minimal.c) */
/* */
/************************************************************************/
void pj_prepare (PJ *P, const char *description, void (*freeup)(struct PJconsts *), size_t sizeof_struct_opaque) {
P->descr = description;
P->pfree = freeup;
P->opaque = pj_calloc (1, sizeof_struct_opaque);
}
proj-4.9.3/src/PJ_sts.c 0000644 0000000 0000000 00000022013 12761101536 011525 0000000 0000000 #define PJ_LIB__
# include
PROJ_HEAD(kav5, "Kavraisky V") "\n\tPCyl., Sph.";
PROJ_HEAD(qua_aut, "Quartic Authalic") "\n\tPCyl., Sph.";
PROJ_HEAD(fouc, "Foucaut") "\n\tPCyl., Sph.";
PROJ_HEAD(mbt_s, "McBryde-Thomas Flat-Polar Sine (No. 1)") "\n\tPCyl., Sph.";
struct pj_opaque {
double C_x, C_y, C_p; \
int tan_mode;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double c;
xy.x = Q->C_x * lp.lam * cos(lp.phi);
xy.y = Q->C_y;
lp.phi *= Q->C_p;
c = cos(lp.phi);
if (Q->tan_mode) {
xy.x *= c * c;
xy.y *= tan (lp.phi);
} else {
xy.x /= c;
xy.y *= sin (lp.phi);
}
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double c;
xy.y /= Q->C_y;
c = cos (lp.phi = Q->tan_mode ? atan (xy.y) : aasin (P->ctx, xy.y));
lp.phi /= Q->C_p;
lp.lam = xy.x / (Q->C_x * cos(lp.phi));
if (Q->tan_mode)
lp.lam /= c * c;
else
lp.lam *= c;
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
static PJ *setup(PJ *P, double p, double q, int mode) {
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
P->opaque->C_x = q / p;
P->opaque->C_y = p;
P->opaque->C_p = 1/ q;
P->opaque->tan_mode = mode;
return P;
}
PJ *PROJECTION(fouc) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
return setup(P, 2., 2., 1);
}
#ifndef PJ_SELFTEST
int pj_fouc_selftest (void) {return 0;}
#else
int pj_fouc_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=fouc +ellps=GRS80 +lat_1=0.5 +lat_2=2 +n=0.5"};
char s_args[] = {"+proj=fouc +a=6400000 +lat_1=0.5 +lat_2=2 +n=0.5"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{222588.12067589167, 111322.31670069379},
{222588.12067589167, -111322.31670069379},
{-222588.12067589167, 111322.31670069379},
{-222588.12067589167, -111322.31670069379},
};
XY s_fwd_expect[] = {
{223351.10900341379, 111703.9077217125},
{223351.10900341379, -111703.9077217125},
{-223351.10900341379, 111703.9077217125},
{-223351.10900341379, -111703.9077217125},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{0.0017966305685702751, 0.00089831528410111959},
{0.0017966305685702751, -0.00089831528410111959},
{-0.0017966305685702751, 0.00089831528410111959},
{-0.0017966305685702751, -0.00089831528410111959},
};
LP s_inv_expect[] = {
{0.0017904931101116717, 0.00089524655487369749},
{0.0017904931101116717, -0.00089524655487369749},
{-0.0017904931101116717, 0.00089524655487369749},
{-0.0017904931101116717, -0.00089524655487369749},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
PJ *PROJECTION(kav5) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
return setup(P, 1.50488, 1.35439, 0);
}
#ifndef PJ_SELFTEST
int pj_kav5_selftest (void) {return 0;}
#else
int pj_kav5_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=kav5 +ellps=GRS80 +lat_1=0.5 +lat_2=2 +n=0.5"};
char s_args[] = {"+proj=kav5 +a=6400000 +lat_1=0.5 +lat_2=2 +n=0.5"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{200360.90530882866, 123685.08247699818},
{200360.90530882866, -123685.08247699818},
{-200360.90530882866, 123685.08247699818},
{-200360.90530882866, -123685.08247699818},
};
XY s_fwd_expect[] = {
{201047.7031108776, 124109.05062917093},
{201047.7031108776, -124109.05062917093},
{-201047.7031108776, 124109.05062917093},
{-201047.7031108776, -124109.05062917093},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{0.0019962591348533314, 0.00080848256185253912},
{0.0019962591348533314, -0.00080848256185253912},
{-0.0019962591348533314, 0.00080848256185253912},
{-0.0019962591348533314, -0.00080848256185253912},
};
LP s_inv_expect[] = {
{0.0019894397264987643, 0.00080572070962591153},
{0.0019894397264987643, -0.00080572070962591153},
{-0.0019894397264987643, 0.00080572070962591153},
{-0.0019894397264987643, -0.00080572070962591153},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
PJ *PROJECTION(qua_aut) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
return setup(P, 2., 2., 0);
}
#ifndef PJ_SELFTEST
int pj_qua_aut_selftest (void) {return 0;}
#else
int pj_qua_aut_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=qua_aut +ellps=GRS80 +lat_1=0.5 +lat_2=2 +n=0.5"};
char s_args[] = {"+proj=qua_aut +a=6400000 +lat_1=0.5 +lat_2=2 +n=0.5"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{222613.54903309655, 111318.07788798446},
{222613.54903309655, -111318.07788798446},
{-222613.54903309655, 111318.07788798446},
{-222613.54903309655, -111318.07788798446},
};
XY s_fwd_expect[] = {
{223376.62452402918, 111699.65437918637},
{223376.62452402918, -111699.65437918637},
{-223376.62452402918, 111699.65437918637},
{-223376.62452402918, -111699.65437918637},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{0.0017966305684046586, 0.00089831528412872229},
{0.0017966305684046586, -0.00089831528412872229},
{-0.0017966305684046586, 0.00089831528412872229},
{-0.0017966305684046586, -0.00089831528412872229},
};
LP s_inv_expect[] = {
{0.0017904931099477471, 0.00089524655490101819},
{0.0017904931099477471, -0.00089524655490101819},
{-0.0017904931099477471, 0.00089524655490101819},
{-0.0017904931099477471, -0.00089524655490101819},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
PJ *PROJECTION(mbt_s) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
return setup(P, 1.48875, 1.36509, 0);
}
#ifndef PJ_SELFTEST
int pj_mbt_s_selftest (void) {return 0;}
#else
int pj_mbt_s_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=mbt_s +ellps=GRS80 +lat_1=0.5 +lat_2=2 +n=0.5"};
char s_args[] = {"+proj=mbt_s +a=6400000 +lat_1=0.5 +lat_2=2 +n=0.5"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{204131.51785027285, 121400.33022550763},
{204131.51785027285, -121400.33022550763},
{-204131.51785027285, 121400.33022550763},
{-204131.51785027285, -121400.33022550763},
};
XY s_fwd_expect[] = {
{204831.24057099217, 121816.46669603503},
{204831.24057099217, -121816.46669603503},
{-204831.24057099217, 121816.46669603503},
{-204831.24057099217, -121816.46669603503},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{0.0019593827209883237, 0.00082369854658027549},
{0.0019593827209883237, -0.00082369854658027549},
{-0.0019593827209883237, 0.00082369854658027549},
{-0.0019593827209883237, -0.00082369854658027549},
};
LP s_inv_expect[] = {
{0.0019526892859206603, 0.00082088471512331508},
{0.0019526892859206603, -0.00082088471512331508},
{-0.0019526892859206603, 0.00082088471512331508},
{-0.0019526892859206603, -0.00082088471512331508},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_bonne.c 0000644 0000000 0000000 00000010546 12761101536 012025 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(bonne, "Bonne (Werner lat_1=90)")
"\n\tConic Sph&Ell\n\tlat_1=";
#define EPS10 1e-10
struct pj_opaque {
double phi1;
double cphi1;
double am1;
double m1;
double *en;
};
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double rh, E, c;
rh = Q->am1 + Q->m1 - pj_mlfn(lp.phi, E = sin(lp.phi), c = cos(lp.phi), Q->en);
E = c * lp.lam / (rh * sqrt(1. - P->es * E * E));
xy.x = rh * sin(E);
xy.y = Q->am1 - rh * cos(E);
return xy;
}
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double E, rh;
rh = Q->cphi1 + Q->phi1 - lp.phi;
if (fabs(rh) > EPS10) {
xy.x = rh * sin(E = lp.lam * cos(lp.phi) / rh);
xy.y = Q->cphi1 - rh * cos(E);
} else
xy.x = xy.y = 0.;
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double rh;
rh = hypot(xy.x, xy.y = Q->cphi1 - xy.y);
lp.phi = Q->cphi1 + Q->phi1 - rh;
if (fabs(lp.phi) > M_HALFPI) I_ERROR;
if (fabs(fabs(lp.phi) - M_HALFPI) <= EPS10)
lp.lam = 0.;
else
lp.lam = rh * atan2(xy.x, xy.y) / cos(lp.phi);
return lp;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double s, rh;
rh = hypot(xy.x, xy.y = Q->am1 - xy.y);
lp.phi = pj_inv_mlfn(P->ctx, Q->am1 + Q->m1 - rh, P->es, Q->en);
if ((s = fabs(lp.phi)) < M_HALFPI) {
s = sin(lp.phi);
lp.lam = rh * atan2(xy.x, xy.y) *
sqrt(1. - P->es * s * s) / cos(lp.phi);
} else if (fabs(s - M_HALFPI) <= EPS10)
lp.lam = 0.;
else I_ERROR;
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque->en);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(bonne) {
double c;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
if (fabs(Q->phi1) < EPS10) E_ERROR(-23);
if (P->es) {
Q->en = pj_enfn(P->es);
Q->m1 = pj_mlfn(Q->phi1, Q->am1 = sin(Q->phi1),
c = cos(Q->phi1), Q->en);
Q->am1 = c / (sqrt(1. - P->es * Q->am1 * Q->am1) * Q->am1);
P->inv = e_inverse;
P->fwd = e_forward;
} else {
if (fabs(Q->phi1) + EPS10 >= M_HALFPI)
Q->cphi1 = 0.;
else
Q->cphi1 = 1. / tan(Q->phi1);
P->inv = s_inverse;
P->fwd = s_forward;
}
return P;
}
#ifndef PJ_SELFTEST
int pj_bonne_selftest (void) {return 0;}
#else
int pj_bonne_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=bonne +ellps=GRS80 +lat_1=0.5 +lat_2=2"};
char s_args[] = {"+proj=bonne +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222605.29609715697, 55321.139565494814},
{ 222605.29609923941, -165827.64779905154},
{-222605.29609715697, 55321.139565494814},
{-222605.29609923941, -165827.64779905154},
};
XY s_fwd_expect[] = {
{ 223368.11557252839, 55884.555246393575},
{ 223368.11557463196, -167517.59936969393},
{-223368.11557252839, 55884.555246393575},
{-223368.11557463196, -167517.59936969393},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.0017966987691132891, 0.50090436853737497},
{ 0.0017966982774478867, 0.4990956309655612},
{-0.0017966987691132891, 0.50090436853737497},
{-0.0017966982774478867, 0.4990956309655612},
};
LP s_inv_expect[] = {
{ 0.0017905615332457991, 0.50089524631087834},
{ 0.0017905610449335603, 0.49910475320072978},
{-0.0017905615332457991, 0.50089524631087834},
{-0.0017905610449335603, 0.49910475320072978},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
proj-4.9.3/src/pj_ellps.c 0000644 0000000 0000000 00000005616 12761101536 012145 0000000 0000000 /* definition of standard geoids */
#define PJ_ELLPS__
#include "projects.h"
C_NAMESPACE_VAR struct PJ_ELLPS
pj_ellps[] = {
{"MERIT", "a=6378137.0", "rf=298.257", "MERIT 1983"},
{"SGS85", "a=6378136.0", "rf=298.257", "Soviet Geodetic System 85"},
{"GRS80", "a=6378137.0", "rf=298.257222101", "GRS 1980(IUGG, 1980)"},
{"IAU76", "a=6378140.0", "rf=298.257", "IAU 1976"},
{"airy", "a=6377563.396", "b=6356256.910", "Airy 1830"},
{"APL4.9", "a=6378137.0.", "rf=298.25", "Appl. Physics. 1965"},
{"NWL9D", "a=6378145.0.", "rf=298.25", "Naval Weapons Lab., 1965"},
{"mod_airy", "a=6377340.189", "b=6356034.446", "Modified Airy"},
{"andrae", "a=6377104.43", "rf=300.0", "Andrae 1876 (Den., Iclnd.)"},
{"aust_SA", "a=6378160.0", "rf=298.25", "Australian Natl & S. Amer. 1969"},
{"GRS67", "a=6378160.0", "rf=298.2471674270", "GRS 67(IUGG 1967)"},
{"bessel", "a=6377397.155", "rf=299.1528128", "Bessel 1841"},
{"bess_nam", "a=6377483.865", "rf=299.1528128", "Bessel 1841 (Namibia)"},
{"clrk66", "a=6378206.4", "b=6356583.8", "Clarke 1866"},
{"clrk80", "a=6378249.145", "rf=293.4663", "Clarke 1880 mod."},
{"clrk80ign", "a=6378249.2", "rf=293.4660212936269", "Clarke 1880 (IGN)."},
{"CPM", "a=6375738.7", "rf=334.29", "Comm. des Poids et Mesures 1799"},
{"delmbr", "a=6376428.", "rf=311.5", "Delambre 1810 (Belgium)"},
{"engelis", "a=6378136.05", "rf=298.2566", "Engelis 1985"},
{"evrst30", "a=6377276.345", "rf=300.8017", "Everest 1830"},
{"evrst48", "a=6377304.063", "rf=300.8017", "Everest 1948"},
{"evrst56", "a=6377301.243", "rf=300.8017", "Everest 1956"},
{"evrst69", "a=6377295.664", "rf=300.8017", "Everest 1969"},
{"evrstSS", "a=6377298.556", "rf=300.8017", "Everest (Sabah & Sarawak)"},
{"fschr60", "a=6378166.", "rf=298.3", "Fischer (Mercury Datum) 1960"},
{"fschr60m", "a=6378155.", "rf=298.3", "Modified Fischer 1960"},
{"fschr68", "a=6378150.", "rf=298.3", "Fischer 1968"},
{"helmert", "a=6378200.", "rf=298.3", "Helmert 1906"},
{"hough", "a=6378270.0", "rf=297.", "Hough"},
{"intl", "a=6378388.0", "rf=297.", "International 1909 (Hayford)"},
{"krass", "a=6378245.0", "rf=298.3", "Krassovsky, 1942"},
{"kaula", "a=6378163.", "rf=298.24", "Kaula 1961"},
{"lerch", "a=6378139.", "rf=298.257", "Lerch 1979"},
{"mprts", "a=6397300.", "rf=191.", "Maupertius 1738"},
{"new_intl", "a=6378157.5", "b=6356772.2", "New International 1967"},
{"plessis", "a=6376523.", "b=6355863.", "Plessis 1817 (France)"},
{"SEasia", "a=6378155.0", "b=6356773.3205", "Southeast Asia"},
{"walbeck", "a=6376896.0", "b=6355834.8467", "Walbeck"},
{"WGS60", "a=6378165.0", "rf=298.3", "WGS 60"},
{"WGS66", "a=6378145.0", "rf=298.25", "WGS 66"},
{"WGS72", "a=6378135.0", "rf=298.26", "WGS 72"},
{"WGS84", "a=6378137.0", "rf=298.257223563", "WGS 84"},
{"sphere", "a=6370997.0", "b=6370997.0", "Normal Sphere (r=6370997)"},
{NULL, NULL, NULL, NULL}
};
struct PJ_ELLPS *pj_get_ellps_ref()
{
return pj_ellps;
}
proj-4.9.3/src/pj_zpoly1.c 0000644 0000000 0000000 00000002012 12761101536 012247 0000000 0000000 /* evaluate complex polynomial */
#include
/* note: coefficients are always from C_1 to C_n
** i.e. C_0 == (0., 0)
** n should always be >= 1 though no checks are made
*/
COMPLEX
pj_zpoly1(COMPLEX z, COMPLEX *C, int n) {
COMPLEX a;
double t;
a = *(C += n);
while (n-- > 0) {
a.r = (--C)->r + z.r * (t = a.r) - z.i * a.i;
a.i = C->i + z.r * a.i + z.i * t;
}
a.r = z.r * (t = a.r) - z.i * a.i;
a.i = z.r * a.i + z.i * t;
return a;
}
/* evaluate complex polynomial and derivative */
COMPLEX
pj_zpolyd1(COMPLEX z, COMPLEX *C, int n, COMPLEX *der) {
COMPLEX a, b;
double t;
int first = 1;
a = *(C += n);
b = a;
while (n-- > 0) {
if (first) {
first = 0;
} else {
b.r = a.r + z.r * (t = b.r) - z.i * b.i;
b.i = a.i + z.r * b.i + z.i * t;
}
a.r = (--C)->r + z.r * (t = a.r) - z.i * a.i;
a.i = C->i + z.r * a.i + z.i * t;
}
b.r = a.r + z.r * (t = b.r) - z.i * b.i;
b.i = a.i + z.r * b.i + z.i * t;
a.r = z.r * (t = a.r) - z.i * a.i;
a.i = z.r * a.i + z.i * t;
*der = b;
return a;
}
proj-4.9.3/src/PJ_fouc_s.c 0000644 0000000 0000000 00000005423 12761101536 012200 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(fouc_s, "Foucaut Sinusoidal") "\n\tPCyl., Sph.";
#define MAX_ITER 10
#define LOOP_TOL 1e-7
struct pj_opaque {
double n, n1;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double t;
t = cos(lp.phi);
xy.x = lp.lam * t / (Q->n + Q->n1 * t);
xy.y = Q->n * lp.phi + Q->n1 * sin(lp.phi);
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double V;
int i;
if (Q->n) {
lp.phi = xy.y;
for (i = MAX_ITER; i ; --i) {
lp.phi -= V = (Q->n * lp.phi + Q->n1 * sin(lp.phi) - xy.y ) /
(Q->n + Q->n1 * cos(lp.phi));
if (fabs(V) < LOOP_TOL)
break;
}
if (!i)
lp.phi = xy.y < 0. ? -M_HALFPI : M_HALFPI;
} else
lp.phi = aasin(P->ctx,xy.y);
V = cos(lp.phi);
lp.lam = xy.x * (Q->n + Q->n1 * V) / V;
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(fouc_s) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->n = pj_param(P->ctx, P->params, "dn").f;
if (Q->n < 0. || Q->n > 1.)
E_ERROR(-99)
Q->n1 = 1. - Q->n;
P->es = 0;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_fouc_s_selftest (void) {return 0;}
#else
int pj_fouc_s_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=fouc_s +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223402.14425527424, 111695.40119861449},
{ 223402.14425527424, -111695.40119861449},
{-223402.14425527424, 111695.40119861449},
{-223402.14425527424, -111695.40119861449},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0017904931097838226, 0.000895246554928339},
{ 0.0017904931097838226, -0.000895246554928339},
{-0.0017904931097838226, 0.000895246554928339},
{-0.0017904931097838226, -0.000895246554928339},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_fahey.c 0000644 0000000 0000000 00000003755 12761101536 012024 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(fahey, "Fahey") "\n\tPcyl, Sph.";
#define TOL 1e-6
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
(void) P;
xy.x = tan(0.5 * lp.phi);
xy.y = 1.819152 * xy.x;
xy.x = 0.819152 * lp.lam * asqrt(1 - xy.x * xy.x);
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
(void) P;
xy.y /= 1.819152;
lp.phi = 2. * atan(xy.y);
xy.y = 1. - xy.y * xy.y;
lp.lam = fabs(xy.y) < TOL ? 0. : xy.x / (0.819152 * sqrt(xy.y));
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(fahey) {
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_fahey_selftest (void) {return 0;}
#else
int pj_fahey_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=fahey +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 182993.34464912376, 101603.19356988439},
{ 182993.34464912376, -101603.19356988439},
{-182993.34464912376, 101603.19356988439},
{-182993.34464912376, -101603.19356988439},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{0.0021857886080359551, 0.00098424601668238403},
{0.0021857886080359551, -0.00098424601668238403},
{-0.0021857886080359551, 0.00098424601668238403},
{-0.0021857886080359551, -0.00098424601668238403},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_oea.c 0000644 0000000 0000000 00000006573 12761101536 011475 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(oea, "Oblated Equal Area") "\n\tMisc Sph\n\tn= m= theta=";
struct pj_opaque {
double theta;
double m, n;
double two_r_m, two_r_n, rm, rn, hm, hn;
double cp0, sp0;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double Az, M, N, cp, sp, cl, shz;
cp = cos(lp.phi);
sp = sin(lp.phi);
cl = cos(lp.lam);
Az = aatan2(cp * sin(lp.lam), Q->cp0 * sp - Q->sp0 * cp * cl) + Q->theta;
shz = sin(0.5 * aacos(P->ctx, Q->sp0 * sp + Q->cp0 * cp * cl));
M = aasin(P->ctx, shz * sin(Az));
N = aasin(P->ctx, shz * cos(Az) * cos(M) / cos(M * Q->two_r_m));
xy.y = Q->n * sin(N * Q->two_r_n);
xy.x = Q->m * sin(M * Q->two_r_m) * cos(N) / cos(N * Q->two_r_n);
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double N, M, xp, yp, z, Az, cz, sz, cAz;
N = Q->hn * aasin(P->ctx,xy.y * Q->rn);
M = Q->hm * aasin(P->ctx,xy.x * Q->rm * cos(N * Q->two_r_n) / cos(N));
xp = 2. * sin(M);
yp = 2. * sin(N) * cos(M * Q->two_r_m) / cos(M);
cAz = cos(Az = aatan2(xp, yp) - Q->theta);
z = 2. * aasin(P->ctx, 0.5 * hypot(xp, yp));
sz = sin(z);
cz = cos(z);
lp.phi = aasin(P->ctx, Q->sp0 * cz + Q->cp0 * sz * cAz);
lp.lam = aatan2(sz * sin(Az),
Q->cp0 * cz - Q->sp0 * sz * cAz);
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(oea) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
if (((Q->n = pj_param(P->ctx, P->params, "dn").f) <= 0.) ||
((Q->m = pj_param(P->ctx, P->params, "dm").f) <= 0.))
E_ERROR(-39)
else {
Q->theta = pj_param(P->ctx, P->params, "rtheta").f;
Q->sp0 = sin(P->phi0);
Q->cp0 = cos(P->phi0);
Q->rn = 1./ Q->n;
Q->rm = 1./ Q->m;
Q->two_r_n = 2. * Q->rn;
Q->two_r_m = 2. * Q->rm;
Q->hm = 0.5 * Q->m;
Q->hn = 0.5 * Q->n;
P->fwd = s_forward;
P->inv = s_inverse;
P->es = 0.;
}
return P;
}
#ifndef PJ_SELFTEST
int pj_oea_selftest (void) {return 0;}
#else
int pj_oea_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=oea +a=6400000 +lat_1=0.5 +lat_2=2 +n=1 +m=2 +theta=3"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 228926.872097864107, 99870.4884300760023},
{ 217242.584036940476, -123247.885607474513},
{-217242.584036940476, 123247.885607474556},
{-228926.872097864078, -99870.4884300760168},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0017411857167771369, 0.000987726819566195693},
{ 0.00183489288577854998, -0.000800312481495174641},
{-0.00183489288577854954, 0.000800312481495174966},
{-0.00174118571677713712, -0.000987726819566195043},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/pj_gc_reader.c 0000644 0000000 0000000 00000016405 12761101536 012737 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Code to read a grid catalog from a .cvs file.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2012, 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.
*****************************************************************************/
#define PJ_LIB__
#include
#include
#include
static int pj_gc_readentry(projCtx ctx, PAFile fid, PJ_GridCatalogEntry *entry);
/************************************************************************/
/* pj_gc_readcatalog() */
/* */
/* Read a grid catalog from a .csv file. */
/************************************************************************/
PJ_GridCatalog *pj_gc_readcatalog( projCtx ctx, const char *catalog_name )
{
PAFile fid;
PJ_GridCatalog *catalog;
int entry_max;
char line[302];
fid = pj_open_lib( ctx, (char *) catalog_name, "r" );
if (fid == NULL)
return NULL;
/* discard title line */
pj_ctx_fgets(ctx, line, sizeof(line)-1, fid);
catalog = (PJ_GridCatalog *) calloc(1,sizeof(PJ_GridCatalog));
if( !catalog )
return NULL;
catalog->catalog_name = strdup(catalog_name);
entry_max = 10;
catalog->entries = (PJ_GridCatalogEntry *)
malloc(entry_max * sizeof(PJ_GridCatalogEntry));
while( pj_gc_readentry( ctx, fid,
catalog->entries+catalog->entry_count) == 0)
{
catalog->entry_count++;
if( catalog->entry_count == entry_max )
{
entry_max = entry_max * 2;
catalog->entries = (PJ_GridCatalogEntry *)
realloc(catalog->entries,
entry_max * sizeof(PJ_GridCatalogEntry));
if (catalog->entries == NULL )
return NULL;
}
}
return catalog;
}
/************************************************************************/
/* pj_gc_read_csv_line() */
/* */
/* Simple csv line splitter with fixed maximum line size and */
/* token count. */
/************************************************************************/
static int pj_gc_read_csv_line( projCtx ctx, PAFile fid,
char **tokens, int max_tokens )
{
char line[302];
while( pj_ctx_fgets(ctx, line, sizeof(line)-1, fid) != NULL )
{
char *next = line;
int token_count = 0;
while( isspace(*next) )
next++;
/* skip blank and comment lines */
if( next[0] == '#' || next[0] == '\0' )
continue;
while( token_count < max_tokens && *next != '\0' )
{
const char *start = next;
while( *next != '\0' && *next != ',' )
next++;
if( *next == ',' )
{
*next = '\0';
next++;
}
tokens[token_count++] = strdup(start);
}
return token_count;
}
return 0;
}
/************************************************************************/
/* pj_gc_parsedate() */
/* */
/* Parse a date into a floating point year value. Acceptable */
/* values are "yyyy.fraction" and "yyyy-mm-dd". Anything else */
/* returns 0.0. */
/************************************************************************/
double pj_gc_parsedate( projCtx ctx, const char *date_string )
{
(void) ctx;
if( strlen(date_string) == 10
&& date_string[4] == '-' && date_string[7] == '-' )
{
int year = atoi(date_string);
int month = atoi(date_string+5);
int day = atoi(date_string+8);
/* simplified calculation so we don't need to know all about months */
return year + ((month-1) * 31 + (day-1)) / 372.0;
}
else
{
return pj_atof(date_string);
}
}
/************************************************************************/
/* pj_gc_readentry() */
/* */
/* Read one catalog entry from the file */
/* */
/* Format: */
/* gridname,ll_long,ll_lat,ur_long,ur_lat,priority,date */
/************************************************************************/
static int pj_gc_readentry(projCtx ctx, PAFile fid, PJ_GridCatalogEntry *entry)
{
#define MAX_TOKENS 30
char *tokens[MAX_TOKENS];
int token_count, i;
int error = 0;
memset( entry, 0, sizeof(PJ_GridCatalogEntry) );
token_count = pj_gc_read_csv_line( ctx, fid, tokens, MAX_TOKENS );
if( token_count < 5 )
{
error = 1; /* TODO: need real error codes */
if( token_count != 0 )
pj_log( ctx, PJ_LOG_ERROR, "Short line in grid catalog." );
}
else
{
memset( entry, 0, sizeof(PJ_GridCatalogEntry));
entry->definition = strdup( tokens[0] );
entry->region.ll_long = dmstor_ctx( ctx, tokens[1], NULL );
entry->region.ll_lat = dmstor_ctx( ctx, tokens[2], NULL );
entry->region.ur_long = dmstor_ctx( ctx, tokens[3], NULL );
entry->region.ur_lat = dmstor_ctx( ctx, tokens[4], NULL );
if( token_count > 5 )
entry->priority = atoi( tokens[5] ); /* defaults to zero */
if( token_count > 6 )
entry->date = pj_gc_parsedate( ctx, tokens[6] );
}
for( i = 0; i < token_count; i++ )
free( tokens[i] );
return error;
}
proj-4.9.3/src/pj_datums.c 0000644 0000000 0000000 00000010660 12761101536 012316 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Built in datum list.
* Author: Frank Warmerdam, warmerda@home.com
*
******************************************************************************
* 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.
*****************************************************************************/
#define PJ_DATUMS__
#include
/*
* The ellipse code must match one from pj_ellps.c. The datum id should
* be kept to 12 characters or less if possible. Use the official OGC
* datum name for the comments if available.
*/
C_NAMESPACE_VAR struct PJ_DATUMS pj_datums[] = {
/* id definition ellipse comments */
/* -- ---------- ------- -------- */
{"WGS84", "towgs84=0,0,0", "WGS84", ""},
{"GGRS87", "towgs84=-199.87,74.79,246.62", "GRS80",
"Greek_Geodetic_Reference_System_1987"},
{"NAD83", "towgs84=0,0,0", "GRS80",
"North_American_Datum_1983"},
{"NAD27", "nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",
"clrk66",
"North_American_Datum_1927"},
{"potsdam", "towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7",
"bessel",
"Potsdam Rauenberg 1950 DHDN"},
{"carthage","towgs84=-263.0,6.0,431.0", "clrk80ign",
"Carthage 1934 Tunisia"},
{"hermannskogel", "towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232",
"bessel",
"Hermannskogel"},
{"ire65", "towgs84=482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",
"mod_airy",
"Ireland 1965"},
{"nzgd49", "towgs84=59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",
"intl", "New Zealand Geodetic Datum 1949"},
{"OSGB36", "towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",
"airy", "Airy 1830"},
{NULL, NULL, NULL, NULL}
};
struct PJ_DATUMS *pj_get_datums_ref()
{
return pj_datums;
}
C_NAMESPACE_VAR struct PJ_PRIME_MERIDIANS pj_prime_meridians[] = {
/* id definition */
/* -- ---------- */
{"greenwich", "0dE"},
{"lisbon", "9d07'54.862\"W"},
{"paris", "2d20'14.025\"E"},
{"bogota", "74d04'51.3\"W"},
{"madrid", "3d41'16.58\"W"},
{"rome", "12d27'8.4\"E"},
{"bern", "7d26'22.5\"E"},
{"jakarta", "106d48'27.79\"E"},
{"ferro", "17d40'W"},
{"brussels", "4d22'4.71\"E"},
{"stockholm", "18d3'29.8\"E"},
{"athens", "23d42'58.815\"E"},
{"oslo", "10d43'22.5\"E"},
{NULL, NULL}
};
struct PJ_PRIME_MERIDIANS *pj_get_prime_meridians_ref()
{
return pj_prime_meridians;
}
proj-4.9.3/src/PJ_aitoff.c 0000644 0000000 0000000 00000021430 12761101536 012166 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Implementation of the aitoff (Aitoff) and wintri (Winkel Tripel)
* projections.
* Author: Gerald Evenden (1995)
* Drazen Tutic, Lovro Gradiser (2015) - add inverse
* Thomas Knudsen (2016) - revise/add regression tests
*
******************************************************************************
* Copyright (c) 1995, Gerald Evenden
*
* 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.
*****************************************************************************/
#define PJ_LIB__
#include
struct pj_opaque {
double cosphi1;
int mode;
};
PROJ_HEAD(aitoff, "Aitoff") "\n\tMisc Sph";
PROJ_HEAD(wintri, "Winkel Tripel") "\n\tMisc Sph\n\tlat_1";
#if 0
FORWARD(s_forward); /* spheroid */
#endif
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double c, d;
if((d = acos(cos(lp.phi) * cos(c = 0.5 * lp.lam)))) {/* basic Aitoff */
xy.x = 2. * d * cos(lp.phi) * sin(c) * (xy.y = 1. / sin(d));
xy.y *= d * sin(lp.phi);
} else
xy.x = xy.y = 0.;
if (Q->mode) { /* Winkel Tripel */
xy.x = (xy.x + lp.lam * Q->cosphi1) * 0.5;
xy.y = (xy.y + lp.phi) * 0.5;
}
return (xy);
}
/***********************************************************************************
*
* Inverse functions added by Drazen Tutic and Lovro Gradiser based on paper:
*
* I.Özbug Biklirici and Cengizhan Ipbüker. A General Algorithm for the Inverse
* Transformation of Map Projections Using Jacobian Matrices. In Proceedings of the
* Third International Symposium Mathematical & Computational Applications,
* pages 175{182, Turkey, September 2002.
*
* Expected accuracy is defined by EPSILON = 1e-12. Should be appropriate for
* most applications of Aitoff and Winkel Tripel projections.
*
* Longitudes of 180W and 180E can be mixed in solution obtained.
*
* Inverse for Aitoff projection in poles is undefined, longitude value of 0 is assumed.
*
* Contact : dtutic@geof.hr
* Date: 2015-02-16
*
************************************************************************************/
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
int iter, MAXITER = 10, round = 0, MAXROUND = 20;
double EPSILON = 1e-12, D, C, f1, f2, f1p, f1l, f2p, f2l, dp, dl, sl, sp, cp, cl, x, y;
if ((fabs(xy.x) < EPSILON) && (fabs(xy.y) < EPSILON )) { lp.phi = 0.; lp.lam = 0.; return lp; }
/* intial values for Newton-Raphson method */
lp.phi = xy.y; lp.lam = xy.x;
do {
iter = 0;
do {
sl = sin(lp.lam * 0.5); cl = cos(lp.lam * 0.5);
sp = sin(lp.phi); cp = cos(lp.phi);
D = cp * cl;
C = 1. - D * D;
D = acos(D) / pow(C, 1.5);
f1 = 2. * D * C * cp * sl;
f2 = D * C * sp;
f1p = 2.* (sl * cl * sp * cp / C - D * sp * sl);
f1l = cp * cp * sl * sl / C + D * cp * cl * sp * sp;
f2p = sp * sp * cl / C + D * sl * sl * cp;
f2l = 0.5 * (sp * cp * sl / C - D * sp * cp * cp * sl * cl);
if (Q->mode) { /* Winkel Tripel */
f1 = 0.5 * (f1 + lp.lam * Q->cosphi1);
f2 = 0.5 * (f2 + lp.phi);
f1p *= 0.5;
f1l = 0.5 * (f1l + Q->cosphi1);
f2p = 0.5 * (f2p + 1.);
f2l *= 0.5;
}
f1 -= xy.x; f2 -= xy.y;
dl = (f2 * f1p - f1 * f2p) / (dp = f1p * f2l - f2p * f1l);
dp = (f1 * f2l - f2 * f1l) / dp;
while (dl > M_PI) dl -= M_PI; /* set to interval [-M_PI, M_PI] */
while (dl < -M_PI) dl += M_PI; /* set to interval [-M_PI, M_PI] */
lp.phi -= dp; lp.lam -= dl;
} while ((fabs(dp) > EPSILON || fabs(dl) > EPSILON) && (iter++ < MAXITER));
if (lp.phi > M_PI_2) lp.phi -= 2.*(lp.phi-M_PI_2); /* correct if symmetrical solution for Aitoff */
if (lp.phi < -M_PI_2) lp.phi -= 2.*(lp.phi+M_PI_2); /* correct if symmetrical solution for Aitoff */
if ((fabs(fabs(lp.phi) - M_PI_2) < EPSILON) && (!Q->mode)) lp.lam = 0.; /* if pole in Aitoff, return longitude of 0 */
/* calculate x,y coordinates with solution obtained */
if((D = acos(cos(lp.phi) * cos(C = 0.5 * lp.lam)))) {/* Aitoff */
x = 2. * D * cos(lp.phi) * sin(C) * (y = 1. / sin(D));
y *= D * sin(lp.phi);
} else
x = y = 0.;
if (Q->mode) { /* Winkel Tripel */
x = (x + lp.lam * Q->cosphi1) * 0.5;
y = (y + lp.phi) * 0.5;
}
/* if too far from given values of x,y, repeat with better approximation of phi,lam */
} while (((fabs(xy.x-x) > EPSILON) || (fabs(xy.y-y) > EPSILON)) && (round++ < MAXROUND));
if (iter == MAXITER && round == MAXROUND) fprintf(stderr, "Warning: Accuracy of 1e-12 not reached. Last increments: dlat=%e and dlon=%e\n", dp, dl);
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
static PJ *setup(PJ *P) {
P->inv = s_inverse;
P->fwd = s_forward;
P->es = 0.;
return P;
}
PJ *PROJECTION(aitoff) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->mode = 0;
return setup(P);
}
PJ *PROJECTION(wintri) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->mode = 1;
if (pj_param(P->ctx, P->params, "tlat_1").i) {
if ((Q->cosphi1 = cos(pj_param(P->ctx, P->params, "rlat_1").f)) == 0.)
E_ERROR(-22)
}
else /* 50d28' or acos(2/pi) */
Q->cosphi1 = 0.636619772367581343;
return setup(P);
}
#ifndef PJ_SELFTEST
int pj_aitoff_selftest (void) {return 0;}
#else
int pj_aitoff_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=aitoff +a=6400000 +lat_1=0 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{223379.45881169615, 111706.74288385305},
{223379.45881169615, -111706.74288385305},
{-223379.45881169615, 111706.74288385305},
{-223379.45881169615, -111706.74288385305},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{0.0017904931100388164, 0.00089524655491012516},
{0.0017904931100388164, -0.00089524655491012516},
{-0.0017904931100388164, 0.00089524655491012516},
{-0.0017904931100388164, -0.00089524655491012516},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_wintri_selftest (void) {return 0;}
#else
int pj_wintri_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=wintri +a=6400000 +lat_1=0 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{223390.80153348515, 111703.90750574505},
{223390.80153348515, -111703.90750574505},
{-223390.80153348515, 111703.90750574505},
{-223390.80153348515, -111703.90750574505},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{0.0017904931099113196, 0.00089524655490101819},
{0.0017904931099113196, -0.00089524655490101819},
{-0.0017904931099113196, 0.00089524655490101819},
{-0.0017904931099113196, -0.00089524655490101819},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_bacon.c 0000644 0000000 0000000 00000007543 12761101536 012011 0000000 0000000 # define HLFPI2 2.46740110027233965467 /* (pi/2)^2 */
# define EPS 1e-10
#define PJ_LIB__
#include
struct pj_opaque {
int bacn;
int ortl;
};
PROJ_HEAD(apian, "Apian Globular I") "\n\tMisc Sph, no inv.";
PROJ_HEAD(ortel, "Ortelius Oval") "\n\tMisc Sph, no inv.";
PROJ_HEAD(bacon, "Bacon Globular") "\n\tMisc Sph, no inv.";
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double ax, f;
xy.y = Q->bacn ? M_HALFPI * sin(lp.phi) : lp.phi;
if ((ax = fabs(lp.lam)) >= EPS) {
if (Q->ortl && ax >= M_HALFPI)
xy.x = sqrt(HLFPI2 - lp.phi * lp.phi + EPS) + ax - M_HALFPI;
else {
f = 0.5 * (HLFPI2 / ax + ax);
xy.x = ax - f + sqrt(f * f - xy.y * xy.y);
}
if (lp.lam < 0.) xy.x = - xy.x;
} else
xy.x = 0.;
return (xy);
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(bacon) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->bacn = 1;
Q->ortl = 0;
P->es = 0.;
P->fwd = s_forward;
return P;
}
PJ *PROJECTION(apian) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->bacn = Q->ortl = 0;
P->es = 0.;
P->fwd = s_forward;
return P;
}
PJ *PROJECTION(ortel) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->bacn = 0;
Q->ortl = 1;
P->es = 0.;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_bacon_selftest (void) {return 0;}
#else
int pj_bacon_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=bacon +a=6400000 +lat_1=0 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{223334.13255596498, 175450.72592266591},
{223334.13255596498, -175450.72592266591},
{-223334.13255596498, 175450.72592266591},
{-223334.13255596498, -175450.72592266591},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 0, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
#ifndef PJ_SELFTEST
int pj_apian_selftest (void) {return 0;}
#else
int pj_apian_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=apian +a=6400000 +lat_1=0 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223374.57735525275, 111701.07212763709},
{ 223374.57735525275, -111701.07212763709},
{-223374.57735525275, 111701.07212763709},
{-223374.57735525275, -111701.07212763709},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 0, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
#ifndef PJ_SELFTEST
int pj_ortel_selftest (void) {return 0;}
#else
int pj_ortel_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=ortel +a=6400000 +lat_1=0 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223374.57735525275, 111701.07212763709},
{ 223374.57735525275, -111701.07212763709},
{-223374.57735525275, 111701.07212763709},
{-223374.57735525275, -111701.07212763709},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 0, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/PJ_lcca.c 0000644 0000000 0000000 00000006731 12761101536 011627 0000000 0000000 /* PROJ.4 Cartographic Projection System
*/
#define PJ_LIB__
#include
PROJ_HEAD(lcca, "Lambert Conformal Conic Alternative")
"\n\tConic, Sph&Ell\n\tlat_0=";
#define MAX_ITER 10
#define DEL_TOL 1e-12
struct pj_opaque {
double *en;
double r0, l, M0;
double C;
};
static double fS(double S, double C) { /* func to compute dr */
return S * ( 1. + S * S * C);
}
static double fSp(double S, double C) { /* deriv of fs */
return 1. + 3.* S * S * C;
}
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double S, r, dr;
S = pj_mlfn(lp.phi, sin(lp.phi), cos(lp.phi), Q->en) - Q->M0;
dr = fS(S, Q->C);
r = Q->r0 - dr;
xy.x = P->k0 * (r * sin( lp.lam *= Q->l ) );
xy.y = P->k0 * (Q->r0 - r * cos(lp.lam) );
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double theta, dr, S, dif;
int i;
xy.x /= P->k0;
xy.y /= P->k0;
theta = atan2(xy.x , Q->r0 - xy.y);
dr = xy.y - xy.x * tan(0.5 * theta);
lp.lam = theta / Q->l;
S = dr;
for (i = MAX_ITER; i ; --i) {
S -= (dif = (fS(S, Q->C) - dr) / fSp(S, Q->C));
if (fabs(dif) < DEL_TOL) break;
}
if (!i) I_ERROR
lp.phi = pj_inv_mlfn(P->ctx, S + Q->M0, P->es, Q->en);
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque->en);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(lcca) {
double s2p0, N0, R0, tan0;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
(Q->en = pj_enfn(P->es));
if (!Q->en) E_ERROR_0;
if (!pj_param(P->ctx, P->params, "tlat_0").i) E_ERROR(50);
if (P->phi0 == 0.) E_ERROR(51);
Q->l = sin(P->phi0);
Q->M0 = pj_mlfn(P->phi0, Q->l, cos(P->phi0), Q->en);
s2p0 = Q->l * Q->l;
R0 = 1. / (1. - P->es * s2p0);
N0 = sqrt(R0);
R0 *= P->one_es * N0;
tan0 = tan(P->phi0);
Q->r0 = N0 / tan0;
Q->C = 1. / (6. * R0 * N0);
P->inv = e_inverse;
P->fwd = e_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_lcca_selftest (void) {return 0;}
#else
int pj_lcca_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=lcca +ellps=GRS80 +lat_0=1 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222605.285770237417, 67.8060072715846616},
{ 222740.037637936533, -221125.539829601563},
{-222605.285770237417, 67.8060072715846616},
{-222740.037637936533, -221125.539829601563},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.00179690290525662526, 1.00090436621350798},
{ 0.00179690192174008037, 0.999095632791497268},
{-0.00179690290525662526, 1.00090436621350798},
{-0.00179690192174008037, 0.999095632791497268},
};
return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
}
#endif
proj-4.9.3/src/PJ_ob_tran.c 0000644 0000000 0000000 00000014610 12761101536 012344 0000000 0000000 #define PJ_LIB__
#include
#include
struct pj_opaque {
struct PJconsts *link;
double lamp;
double cphip, sphip;
};
PROJ_HEAD(ob_tran, "General Oblique Transformation") "\n\tMisc Sph"
"\n\to_proj= plus parameters for projection"
"\n\to_lat_p= o_lon_p= (new pole) or"
"\n\to_alpha= o_lon_c= o_lat_c= or"
"\n\to_lon_1= o_lat_1= o_lon_2= o_lat_2=";
#define TOL 1e-10
static XY o_forward(LP lp, PJ *P) { /* spheroid */
struct pj_opaque *Q = P->opaque;
double coslam, sinphi, cosphi;
coslam = cos(lp.lam);
sinphi = sin(lp.phi);
cosphi = cos(lp.phi);
lp.lam = adjlon(aatan2(cosphi * sin(lp.lam), Q->sphip * cosphi * coslam +
Q->cphip * sinphi) + Q->lamp);
lp.phi = aasin(P->ctx,Q->sphip * sinphi - Q->cphip * cosphi * coslam);
return Q->link->fwd(lp, Q->link);
}
static XY t_forward(LP lp, PJ *P) { /* spheroid */
struct pj_opaque *Q = P->opaque;
double cosphi, coslam;
cosphi = cos(lp.phi);
coslam = cos(lp.lam);
lp.lam = adjlon(aatan2(cosphi * sin(lp.lam), sin(lp.phi)) + Q->lamp);
lp.phi = aasin(P->ctx, - cosphi * coslam);
return Q->link->fwd(lp, Q->link);
}
static LP o_inverse(XY xy, PJ *P) { /* spheroid */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double coslam, sinphi, cosphi;
lp = Q->link->inv(xy, Q->link);
if (lp.lam != HUGE_VAL) {
coslam = cos(lp.lam -= Q->lamp);
sinphi = sin(lp.phi);
cosphi = cos(lp.phi);
lp.phi = aasin(P->ctx,Q->sphip * sinphi + Q->cphip * cosphi * coslam);
lp.lam = aatan2(cosphi * sin(lp.lam), Q->sphip * cosphi * coslam -
Q->cphip * sinphi);
}
return lp;
}
static LP t_inverse(XY xy, PJ *P) { /* spheroid */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double cosphi, t;
lp = Q->link->inv(xy, Q->link);
if (lp.lam != HUGE_VAL) {
cosphi = cos(lp.phi);
t = lp.lam - Q->lamp;
lp.lam = aatan2(cosphi * sin(t), - sin(lp.phi));
lp.phi = aasin(P->ctx,cosphi * cos(t));
}
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
if (P->opaque->link)
return pj_dealloc (P->opaque->link);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(ob_tran) {
int i;
double phip;
char *name, *s;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
/* get name of projection to be translated */
if (!(name = pj_param(P->ctx, P->params, "so_proj").s)) E_ERROR(-26);
for (i = 0; (s = pj_list[i].id) && strcmp(name, s) ; ++i) ;
if (!s || !(Q->link = (*pj_list[i].proj)(0))) E_ERROR(-37);
/* copy existing header into new */
P->es = 0.; /* force to spherical */
Q->link->params = P->params;
Q->link->ctx = P->ctx;
Q->link->over = P->over;
Q->link->geoc = P->geoc;
Q->link->a = P->a;
Q->link->es = P->es;
Q->link->ra = P->ra;
Q->link->lam0 = P->lam0;
Q->link->phi0 = P->phi0;
Q->link->x0 = P->x0;
Q->link->y0 = P->y0;
Q->link->k0 = P->k0;
/* force spherical earth */
Q->link->one_es = Q->link->rone_es = 1.;
Q->link->es = Q->link->e = 0.;
if (!(Q->link = pj_list[i].proj(Q->link))) {
return freeup_new(P);
}
if (pj_param(P->ctx, P->params, "to_alpha").i) {
double lamc, phic, alpha;
lamc = pj_param(P->ctx, P->params, "ro_lon_c").f;
phic = pj_param(P->ctx, P->params, "ro_lat_c").f;
alpha = pj_param(P->ctx, P->params, "ro_alpha").f;
/*
if (fabs(phic) <= TOL ||
fabs(fabs(phic) - HALFPI) <= TOL ||
fabs(fabs(alpha) - HALFPI) <= TOL)
*/
if (fabs(fabs(phic) - M_HALFPI) <= TOL)
E_ERROR(-32);
Q->lamp = lamc + aatan2(-cos(alpha), -sin(alpha) * sin(phic));
phip = aasin(P->ctx,cos(phic) * sin(alpha));
} else if (pj_param(P->ctx, P->params, "to_lat_p").i) { /* specified new pole */
Q->lamp = pj_param(P->ctx, P->params, "ro_lon_p").f;
phip = pj_param(P->ctx, P->params, "ro_lat_p").f;
} else { /* specified new "equator" points */
double lam1, lam2, phi1, phi2, con;
lam1 = pj_param(P->ctx, P->params, "ro_lon_1").f;
phi1 = pj_param(P->ctx, P->params, "ro_lat_1").f;
lam2 = pj_param(P->ctx, P->params, "ro_lon_2").f;
phi2 = pj_param(P->ctx, P->params, "ro_lat_2").f;
if (fabs(phi1 - phi2) <= TOL ||
(con = fabs(phi1)) <= TOL ||
fabs(con - M_HALFPI) <= TOL ||
fabs(fabs(phi2) - M_HALFPI) <= TOL) E_ERROR(-33);
Q->lamp = atan2(cos(phi1) * sin(phi2) * cos(lam1) -
sin(phi1) * cos(phi2) * cos(lam2),
sin(phi1) * cos(phi2) * sin(lam2) -
cos(phi1) * sin(phi2) * sin(lam1));
phip = atan(-cos(Q->lamp - lam1) / tan(phi1));
}
if (fabs(phip) > TOL) { /* oblique */
Q->cphip = cos(phip);
Q->sphip = sin(phip);
P->fwd = o_forward;
P->inv = Q->link->inv ? o_inverse : 0;
} else { /* transverse */
P->fwd = t_forward;
P->inv = Q->link->inv ? t_inverse : 0;
}
return P;
}
#ifndef PJ_SELFTEST
int pj_ob_tran_selftest (void) {return 0;}
#else
int pj_ob_tran_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=ob_tran +a=6400000 +o_proj=latlon +o_lon_p=20 +o_lat_p=20 +lon_0=180"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{-2.6856872138416592, 1.2374302350496296},
{-2.6954069748943286, 1.2026833954513816},
{-2.8993663925401947, 1.2374302350496296},
{-2.8896466314875244, 1.2026833954513816},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 121.5518748407577, -2.5361001573966084},
{ 63.261184340201858, 17.585319578673531},
{-141.10073322351622, 26.091712304855108},
{-65.862385598848391, 51.830295078417215},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/pj_utils.c 0000644 0000000 0000000 00000016002 12761101536 012155 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Some utility functions we don't want to bother putting in
* their own source files.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2001, 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.
*****************************************************************************/
#define PJ_LIB__
#include
#include
#include
/************************************************************************/
/* pj_is_latlong() */
/* */
/* Returns TRUE if this coordinate system object is */
/* geographic. */
/************************************************************************/
int pj_is_latlong( PJ *pj )
{
return pj == NULL || pj->is_latlong;
}
/************************************************************************/
/* pj_is_geocent() */
/* */
/* Returns TRUE if this coordinate system object is geocentric. */
/************************************************************************/
int pj_is_geocent( PJ *pj )
{
return pj != NULL && pj->is_geocent;
}
/************************************************************************/
/* pj_latlong_from_proj() */
/* */
/* Return a PJ* definition defining the lat/long coordinate */
/* system on which a projection is based. If the coordinate */
/* system passed in is latlong, a clone of the same will be */
/* returned. */
/************************************************************************/
PJ *pj_latlong_from_proj( PJ *pj_in )
{
char defn[512];
int got_datum = FALSE;
pj_errno = 0;
strcpy( defn, "+proj=latlong" );
if( pj_param(pj_in->ctx, pj_in->params, "tdatum").i )
{
got_datum = TRUE;
sprintf( defn+strlen(defn), " +datum=%s",
pj_param(pj_in->ctx, pj_in->params,"sdatum").s );
}
else if( pj_param(pj_in->ctx, pj_in->params, "tellps").i )
{
sprintf( defn+strlen(defn), " +ellps=%s",
pj_param(pj_in->ctx, pj_in->params,"sellps").s );
}
else if( pj_param(pj_in->ctx,pj_in->params, "ta").i )
{
sprintf( defn+strlen(defn), " +a=%s",
pj_param(pj_in->ctx,pj_in->params,"sa").s );
if( pj_param(pj_in->ctx,pj_in->params, "tb").i )
sprintf( defn+strlen(defn), " +b=%s",
pj_param(pj_in->ctx,pj_in->params,"sb").s );
else if( pj_param(pj_in->ctx,pj_in->params, "tes").i )
sprintf( defn+strlen(defn), " +es=%s",
pj_param(pj_in->ctx,pj_in->params,"ses").s );
else if( pj_param(pj_in->ctx,pj_in->params, "tf").i )
sprintf( defn+strlen(defn), " +f=%s",
pj_param(pj_in->ctx,pj_in->params,"sf").s );
else
{
char* ptr = defn+strlen(defn);
sprintf( ptr, " +es=%.16g", pj_in->es );
for(; *ptr; ptr++)
{
if( *ptr == ',' )
*ptr = '.';
}
}
}
else
{
pj_ctx_set_errno( pj_in->ctx, -13 );
return NULL;
}
if( !got_datum )
{
if( pj_param(pj_in->ctx,pj_in->params, "ttowgs84").i )
sprintf( defn+strlen(defn), " +towgs84=%s",
pj_param(pj_in->ctx,pj_in->params,"stowgs84").s );
if( pj_param(pj_in->ctx,pj_in->params, "tnadgrids").i )
sprintf( defn+strlen(defn), " +nadgrids=%s",
pj_param(pj_in->ctx,pj_in->params,"snadgrids").s );
}
/* copy over some other information related to ellipsoid */
if( pj_param(pj_in->ctx,pj_in->params, "tR").i )
sprintf( defn+strlen(defn), " +R=%s",
pj_param(pj_in->ctx,pj_in->params,"sR").s );
if( pj_param(pj_in->ctx,pj_in->params, "tR_A").i )
sprintf( defn+strlen(defn), " +R_A" );
if( pj_param(pj_in->ctx,pj_in->params, "tR_V").i )
sprintf( defn+strlen(defn), " +R_V" );
if( pj_param(pj_in->ctx,pj_in->params, "tR_a").i )
sprintf( defn+strlen(defn), " +R_a" );
if( pj_param(pj_in->ctx,pj_in->params, "tR_lat_a").i )
sprintf( defn+strlen(defn), " +R_lat_a=%s",
pj_param(pj_in->ctx,pj_in->params,"sR_lat_a").s );
if( pj_param(pj_in->ctx,pj_in->params, "tR_lat_g").i )
sprintf( defn+strlen(defn), " +R_lat_g=%s",
pj_param(pj_in->ctx,pj_in->params,"sR_lat_g").s );
/* copy over prime meridian */
if( pj_param(pj_in->ctx,pj_in->params, "tpm").i )
sprintf( defn+strlen(defn), " +pm=%s",
pj_param(pj_in->ctx,pj_in->params,"spm").s );
return pj_init_plus_ctx( pj_in->ctx, defn );
}
/************************************************************************/
/* pj_get_spheroid_defn() */
/* */
/* Fetch the internal definition of the spheroid. Note that */
/* you can compute "b" from eccentricity_squared as: */
/* */
/* b = a * sqrt(1 - es) */
/************************************************************************/
void pj_get_spheroid_defn(projPJ defn, double *major_axis, double *eccentricity_squared)
{
if ( major_axis )
*major_axis = defn->a;
if ( eccentricity_squared )
*eccentricity_squared = defn->es;
}
proj-4.9.3/src/PJ_vandg2.c 0000644 0000000 0000000 00000006352 12761101536 012105 0000000 0000000 #define PJ_LIB__
#include
struct pj_opaque {
int vdg3;
};
PROJ_HEAD(vandg2, "van der Grinten II") "\n\tMisc Sph, no inv.";
PROJ_HEAD(vandg3, "van der Grinten III") "\n\tMisc Sph, no inv.";
#define TOL 1e-10
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double x1, at, bt, ct;
bt = fabs(M_TWO_D_PI * lp.phi);
if ((ct = 1. - bt * bt) < 0.)
ct = 0.;
else
ct = sqrt(ct);
if (fabs(lp.lam) < TOL) {
xy.x = 0.;
xy.y = M_PI * (lp.phi < 0. ? -bt : bt) / (1. + ct);
} else {
at = 0.5 * fabs(M_PI / lp.lam - lp.lam / M_PI);
if (Q->vdg3) {
x1 = bt / (1. + ct);
xy.x = M_PI * (sqrt(at * at + 1. - x1 * x1) - at);
xy.y = M_PI * x1;
} else {
x1 = (ct * sqrt(1. + at * at) - at * ct * ct) /
(1. + at * at * bt * bt);
xy.x = M_PI * x1;
xy.y = M_PI * sqrt(1. - x1 * (x1 + 2. * at) + TOL);
}
if ( lp.lam < 0.) xy.x = -xy.x;
if ( lp.phi < 0.) xy.y = -xy.y;
}
return xy;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(vandg2) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->vdg3 = 0;
P->fwd = s_forward;
return P;
}
PJ *PROJECTION(vandg3) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->vdg3 = 1;
P->es = 0.;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_vandg2_selftest (void) {return 0;}
#else
int pj_vandg2_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=vandg2 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223395.24785043663, 111718.49103722633},
{ 223395.24785043663, -111718.49103722633},
{-223395.24785043663, 111718.49103722633},
{-223395.24785043663, -111718.49103722633},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
#ifndef PJ_SELFTEST
int pj_vandg3_selftest (void) {return 0;}
#else
int pj_vandg3_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=vandg3 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223395.24955283134, 111704.51990442065},
{ 223395.24955283134, -111704.51990442065},
{-223395.24955283134, 111704.51990442065},
{-223395.24955283134, -111704.51990442065},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/pj_geocent.c 0000644 0000000 0000000 00000006567 12761101536 012460 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Stub projection for geocentric. The transformation isn't
* really done here since this code is 2D. The real transformation
* is handled by pj_transform.c.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2002, 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.
*****************************************************************************/
#define PJ_LIB__
#include
PROJ_HEAD(geocent, "Geocentric") "\n\t";
static XY forward(LP lp, PJ *P) {
XY xy = {0.0,0.0};
(void) P;
xy.x = lp.lam;
xy.y = lp.phi;
return xy;
}
static LP inverse(XY xy, PJ *P) {
LP lp = {0.0,0.0};
(void) P;
lp.phi = xy.y;
lp.lam = xy.x;
return lp;
}
static void *freeup_new (PJ *P) {
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(geocent) {
P->is_geocent = 1;
P->x0 = 0.0;
P->y0 = 0.0;
P->inv = inverse;
P->fwd = forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_geocent_selftest (void) {return 0;}
#else
int pj_geocent_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=geocent +ellps=GRS80 +lat_1=0.5 +lat_2=2"};
char s_args[] = {"+proj=geocent +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222638.98158654713, 111319.49079327357},
{ 222638.98158654713, -111319.49079327357},
{-222638.98158654713, 111319.49079327357},
{-222638.98158654713, -111319.49079327357},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.0017966305682390426, 0.00089831528411952132},
{ 0.0017966305682390426, -0.00089831528411952132},
{-0.0017966305682390426, 0.00089831528411952132},
{-0.0017966305682390426, -0.00089831528411952132},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
}
#endif
proj-4.9.3/src/pj_inv3d.c 0000644 0000000 0000000 00000002423 12761101536 012042 0000000 0000000 /* general inverse projection */
#define PJ_LIB__
#include
#include
# define EPS 1.0e-12
LPZ /* inverse projection entry */
pj_inv3d(XYZ xyz, PJ *P) {
LPZ lpz;
/* can't do as much preliminary checking as with forward */
if (xyz.x == HUGE_VAL || xyz.y == HUGE_VAL || xyz.z == HUGE_VAL ) {
lpz.lam = lpz.phi = lpz.z = HUGE_VAL;
pj_ctx_set_errno( P->ctx, -15);
return lpz;
}
errno = pj_errno = 0;
P->ctx->last_errno = 0;
xyz.x = (xyz.x * P->to_meter - P->x0) * P->ra; /* descale and de-offset */
xyz.y = (xyz.y * P->to_meter - P->y0) * P->ra;
/* z is not scaled since that is handled by vto_meter before we get here */
/* Check for NULL pointer */
if (P->inv3d != NULL)
{
lpz = (*P->inv3d)(xyz, P); /* inverse project */
if (P->ctx->last_errno )
lpz.lam = lpz.phi = lpz.z = HUGE_VAL;
else {
lpz.lam += P->lam0; /* reduce from del lp.lam */
if (!P->over)
lpz.lam = adjlon(lpz.lam); /* adjust longitude to CM */
/* This may be redundant and never used */
if (P->geoc && fabs(fabs(lpz.phi)-M_HALFPI) > EPS)
lpz.phi = atan(P->one_es * tan(lpz.phi));
}
}
else
{
lpz.lam = lpz.phi = lpz.z = HUGE_VAL;
}
return lpz;
}
proj-4.9.3/src/bin_cs2cs.cmake 0000644 0000000 0000000 00000000543 12761101536 013032 0000000 0000000 set(CS2CS_SRC cs2cs.c
gen_cheb.c
p_series.c)
source_group("Source Files\\Bin" FILES ${CS2CS_SRC})
if(WIN32)
set(CS2CS_SRC ${CS2CS_SRC} emess.c)
endif(WIN32)
add_executable(cs2cs ${CS2CS_SRC} ${CS2CS_INCLUDE})
target_link_libraries(cs2cs ${PROJ_LIBRARIES})
install(TARGETS cs2cs
RUNTIME DESTINATION ${BINDIR})
proj-4.9.3/src/gen_cheb.c 0000644 0000000 0000000 00000004451 12761101536 012063 0000000 0000000 /* generates 'T' option output */
#define PJ_LIB__
#include "projects.h"
#include
#include
#include
#include "emess.h"
#ifndef COEF_LINE_MAX
#define COEF_LINE_MAX 60
#endif
void
gen_cheb(int inverse, projUV (*proj)(projUV), char *s, PJ *P, int iargc, char **iargv) {
int NU = 15, NV = 15, res = -1, errin = 0, pwr;
char *arg, fmt[15];
projUV low, upp, resid;
Tseries *F;
extern void p_series(Tseries *, FILE *, char *);
double (*input)(const char *, char **);
input = inverse ? strtod : dmstor;
if (*s) low.u = input(s, &s); else { low.u = 0; ++errin; }
if (*s == ',') upp.u = input(s+1, &s); else { upp.u = 0; ++errin; }
if (*s == ',') low.v = input(s+1, &s); else { low.v = 0; ++errin; }
if (*s == ',') upp.v = input(s+1, &s); else { upp.v = 0; ++errin; }
if (errin)
emess(16,"null or absent -T parameters");
if (*s == ',') if (*++s != ',') res = strtol(s, &s, 10);
if (*s == ',') if (*++s != ',') NU = strtol(s, &s, 10);
if (*s == ',') if (*++s != ',') NV = strtol(s, &s, 10);
pwr = s && *s && !strcmp(s, ",P");
(void)printf("#proj_%s\n# run-line:\n",
pwr ? "Power" : "Chebyshev");
if (iargc > 0) { /* proj execution audit trail */
int n = 0, L;
for ( ; iargc ; --iargc) {
arg = *iargv++;
if (*arg != '+') {
if (!n) { putchar('#'); ++n; }
(void)printf(" %s%n",arg, &L);
if ((n += L) > 50) { putchar('\n'); n = 0; }
}
}
if (n) putchar('\n');
}
(void)printf("# projection parameters\n");
pj_pr_list(P);
if (low.u == upp.u || low.v >= upp.v)
emess(16,"approx. argument range error");
if (low.u > upp.u)
low.u -= M_TWOPI;
if (NU < 2 || NV < 2)
emess(16,"approx. work dimensions (%d %d) too small",NU,NV);
if (!(F = mk_cheby(low, upp, pow(10., (double)res)*.5, &resid, proj,
NU, NV, pwr)))
emess(16,"generation of approx failed\nreason: %s\n",
pj_strerrno(errno));
(void)printf("%c,%.12g,%.12g,%.12g,%.12g,%.12g\n",inverse?'I':'F',
P->lam0*RAD_TO_DEG,
low.u*(inverse?1.:RAD_TO_DEG),upp.u*(inverse?1.:RAD_TO_DEG),
low.v*(inverse?1.:RAD_TO_DEG),upp.v*(inverse?1.:RAD_TO_DEG));
if (pwr)
strcpy(fmt, "%.15g");
else if (res <= 0)
(void)sprintf(fmt,"%%.%df",-res+1);
else
(void)strcpy(fmt,"%.0f");
p_series(F, stdout, fmt);
(void)printf("# |u,v| sums %g %g\n#end_proj_%s\n",
resid.u, resid.v, pwr ? "Power" : "Chebyshev");
}
proj-4.9.3/src/PJ_natearth2.c 0000644 0000000 0000000 00000006552 12761101536 012616 0000000 0000000 /*
The Natural Earth II projection was designed by Tom Patterson, US National
Park Service, in 2012, using Flex Projector. The polynomial equation was
developed by Bojan Savric and Bernhard Jenny, College of Earth, Ocean,
and Atmospheric Sciences, Oregon State University.
Port to PROJ.4 by Bojan Savric, 4 April 2016
*/
#define PJ_LIB__
#include
PROJ_HEAD(natearth2, "Natural Earth 2") "\n\tPCyl., Sph.";
#define A0 0.84719
#define A1 -0.13063
#define A2 -0.04515
#define A3 0.05494
#define A4 -0.02326
#define A5 0.00331
#define B0 1.01183
#define B1 -0.02625
#define B2 0.01926
#define B3 -0.00396
#define C0 B0
#define C1 (9 * B1)
#define C2 (11 * B2)
#define C3 (13 * B3)
#define EPS 1e-11
#define MAX_Y (0.84719 * 0.535117535153096 * M_PI)
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
double phi2, phi4, phi6;
(void) P;
phi2 = lp.phi * lp.phi;
phi4 = phi2 * phi2;
phi6 = phi2 * phi4;
xy.x = lp.lam * (A0 + A1 * phi2 + phi6 * phi6 * (A2 + A3 * phi2 + A4 * phi4 + A5 * phi6));
xy.y = lp.phi * (B0 + phi4 * phi4 * (B1 + B2 * phi2 + B3 * phi4));
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
double yc, tol, y2, y4, y6, f, fder;
(void) P;
/* make sure y is inside valid range */
if (xy.y > MAX_Y) {
xy.y = MAX_Y;
} else if (xy.y < -MAX_Y) {
xy.y = -MAX_Y;
}
/* latitude */
yc = xy.y;
for (;;) { /* Newton-Raphson */
y2 = yc * yc;
y4 = y2 * y2;
f = (yc * (B0 + y4 * y4 * (B1 + B2 * y2 + B3 * y4))) - xy.y;
fder = C0 + y4 * y4 * (C1 + C2 * y2 + C3 * y4);
yc -= tol = f / fder;
if (fabs(tol) < EPS) {
break;
}
}
lp.phi = yc;
/* longitude */
y2 = yc * yc;
y4 = y2 * y2;
y6 = y2 * y4;
lp.lam = xy.x / (A0 + A1 * y2 + y6 * y6 * (A2 + A3 * y2 + A4 * y4 + A5 * y6));
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(natearth2) {
P->es = 0;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_natearth2_selftest (void) {return 0;}
#else
int pj_natearth2_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=natearth2 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 189255.172934730799, 113022.495810907014},
{ 189255.172934730799, -113022.495810907014},
{-189255.172934730799, 113022.495810907014},
{-189255.172934730799, -113022.495810907014},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00211344929691056112, 0.000884779612080993237},
{ 0.00211344929691056112, -0.000884779612080993237},
{-0.00211344929691056112, 0.000884779612080993237},
{-0.00211344929691056112, -0.000884779612080993237},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/pj_gridinfo.c 0000644 0000000 0000000 00000076367 12761101536 012642 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Functions for handling individual PJ_GRIDINFO's. Includes
* loaders for all formats but CTABLE (in nad_init.c).
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* 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.
*****************************************************************************/
#define PJ_LIB__
#include
#include
#include
#include
#ifdef _WIN32_WCE
/* assert.h includes all Windows API headers and causes 'LP' name clash.
* Here assert we disable assert() for Windows CE.
* TODO - mloskot: re-implement porting friendly assert
*/
# define assert(exp) ((void)0)
#else
# include
#endif /* _WIN32_WCE */
/************************************************************************/
/* swap_words() */
/* */
/* Convert the byte order of the given word(s) in place. */
/************************************************************************/
static int byte_order_test = 1;
#define IS_LSB (1 == ((unsigned char *) (&byte_order_test))[0])
static void swap_words( unsigned char *data, int word_size, int word_count )
{
int word;
for( word = 0; word < word_count; word++ )
{
int i;
for( i = 0; i < word_size/2; i++ )
{
int t;
t = data[i];
data[i] = data[word_size-i-1];
data[word_size-i-1] = t;
}
data += word_size;
}
}
/************************************************************************/
/* pj_gridinfo_free() */
/************************************************************************/
void pj_gridinfo_free( projCtx ctx, PJ_GRIDINFO *gi )
{
if( gi == NULL )
return;
if( gi->child != NULL )
{
PJ_GRIDINFO *child, *next;
for( child = gi->child; child != NULL; child=next)
{
next=child->next;
pj_gridinfo_free( ctx, child );
}
}
if( gi->ct != NULL )
nad_free( gi->ct );
free( gi->gridname );
if( gi->filename != NULL )
free( gi->filename );
pj_dalloc( gi );
}
/************************************************************************/
/* pj_gridinfo_load() */
/* */
/* This function is intended to implement delayed loading of */
/* the data contents of a grid file. The header and related */
/* stuff are loaded by pj_gridinfo_init(). */
/************************************************************************/
int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi )
{
struct CTABLE ct_tmp;
if( gi == NULL || gi->ct == NULL )
return 0;
pj_acquire_lock();
if( gi->ct->cvs != NULL )
{
pj_release_lock();
return 1;
}
memcpy(&ct_tmp, gi->ct, sizeof(struct CTABLE));
/* -------------------------------------------------------------------- */
/* Original platform specific CTable format. */
/* -------------------------------------------------------------------- */
if( strcmp(gi->format,"ctable") == 0 )
{
PAFile fid;
int result;
fid = pj_open_lib( ctx, gi->filename, "rb" );
if( fid == NULL )
{
pj_ctx_set_errno( ctx, -38 );
pj_release_lock();
return 0;
}
result = nad_ctable_load( ctx, &ct_tmp, fid );
pj_ctx_fclose( ctx, fid );
gi->ct->cvs = ct_tmp.cvs;
pj_release_lock();
return result;
}
/* -------------------------------------------------------------------- */
/* CTable2 format. */
/* -------------------------------------------------------------------- */
else if( strcmp(gi->format,"ctable2") == 0 )
{
PAFile fid;
int result;
fid = pj_open_lib( ctx, gi->filename, "rb" );
if( fid == NULL )
{
pj_ctx_set_errno( ctx, -38 );
pj_release_lock();
return 0;
}
result = nad_ctable2_load( ctx, &ct_tmp, fid );
pj_ctx_fclose( ctx, fid );
gi->ct->cvs = ct_tmp.cvs;
pj_release_lock();
return result;
}
/* -------------------------------------------------------------------- */
/* NTv1 format. */
/* We process one line at a time. Note that the array storage */
/* direction (e-w) is different in the NTv1 file and what */
/* the CTABLE is supposed to have. The phi/lam are also */
/* reversed, and we have to be aware of byte swapping. */
/* -------------------------------------------------------------------- */
else if( strcmp(gi->format,"ntv1") == 0 )
{
double *row_buf;
int row;
PAFile fid;
fid = pj_open_lib( ctx, gi->filename, "rb" );
if( fid == NULL )
{
pj_ctx_set_errno( ctx, -38 );
pj_release_lock();
return 0;
}
pj_ctx_fseek( ctx, fid, gi->grid_offset, SEEK_SET );
row_buf = (double *) pj_malloc(gi->ct->lim.lam * sizeof(double) * 2);
ct_tmp.cvs = (FLP *) pj_malloc(gi->ct->lim.lam*gi->ct->lim.phi*sizeof(FLP));
if( row_buf == NULL || ct_tmp.cvs == NULL )
{
pj_ctx_set_errno( ctx, -38 );
pj_release_lock();
return 0;
}
for( row = 0; row < gi->ct->lim.phi; row++ )
{
int i;
FLP *cvs;
double *diff_seconds;
if( pj_ctx_fread( ctx, row_buf,
sizeof(double), gi->ct->lim.lam * 2, fid )
!= (size_t)( 2 * gi->ct->lim.lam ) )
{
pj_dalloc( row_buf );
pj_dalloc( ct_tmp.cvs );
pj_ctx_set_errno( ctx, -38 );
return 0;
}
if( IS_LSB )
swap_words( (unsigned char *) row_buf, 8, gi->ct->lim.lam*2 );
/* convert seconds to radians */
diff_seconds = row_buf;
for( i = 0; i < gi->ct->lim.lam; i++ )
{
cvs = ct_tmp.cvs + (row) * gi->ct->lim.lam
+ (gi->ct->lim.lam - i - 1);
cvs->phi = *(diff_seconds++) * ((M_PI/180.0) / 3600.0);
cvs->lam = *(diff_seconds++) * ((M_PI/180.0) / 3600.0);
}
}
pj_dalloc( row_buf );
pj_ctx_fclose( ctx, fid );
gi->ct->cvs = ct_tmp.cvs;
pj_release_lock();
return 1;
}
/* -------------------------------------------------------------------- */
/* NTv2 format. */
/* We process one line at a time. Note that the array storage */
/* direction (e-w) is different in the NTv2 file and what */
/* the CTABLE is supposed to have. The phi/lam are also */
/* reversed, and we have to be aware of byte swapping. */
/* -------------------------------------------------------------------- */
else if( strcmp(gi->format,"ntv2") == 0 )
{
float *row_buf;
int row;
PAFile fid;
pj_log( ctx, PJ_LOG_DEBUG_MINOR,
"NTv2 - loading grid %s", gi->ct->id );
fid = pj_open_lib( ctx, gi->filename, "rb" );
if( fid == NULL )
{
pj_ctx_set_errno( ctx, -38 );
pj_release_lock();
return 0;
}
pj_ctx_fseek( ctx, fid, gi->grid_offset, SEEK_SET );
row_buf = (float *) pj_malloc(gi->ct->lim.lam * sizeof(float) * 4);
ct_tmp.cvs = (FLP *) pj_malloc(gi->ct->lim.lam*gi->ct->lim.phi*sizeof(FLP));
if( row_buf == NULL || ct_tmp.cvs == NULL )
{
pj_ctx_set_errno( ctx, -38 );
pj_release_lock();
return 0;
}
for( row = 0; row < gi->ct->lim.phi; row++ )
{
int i;
FLP *cvs;
float *diff_seconds;
if( pj_ctx_fread( ctx, row_buf, sizeof(float),
gi->ct->lim.lam*4, fid )
!= (size_t)( 4 * gi->ct->lim.lam ) )
{
pj_dalloc( row_buf );
pj_dalloc( ct_tmp.cvs );
pj_ctx_set_errno( ctx, -38 );
pj_release_lock();
return 0;
}
if( gi->must_swap )
swap_words( (unsigned char *) row_buf, 4,
gi->ct->lim.lam*4 );
/* convert seconds to radians */
diff_seconds = row_buf;
for( i = 0; i < gi->ct->lim.lam; i++ )
{
cvs = ct_tmp.cvs + (row) * gi->ct->lim.lam
+ (gi->ct->lim.lam - i - 1);
cvs->phi = *(diff_seconds++) * ((M_PI/180.0) / 3600.0);
cvs->lam = *(diff_seconds++) * ((M_PI/180.0) / 3600.0);
diff_seconds += 2; /* skip accuracy values */
}
}
pj_dalloc( row_buf );
pj_ctx_fclose( ctx, fid );
gi->ct->cvs = ct_tmp.cvs;
pj_release_lock();
return 1;
}
/* -------------------------------------------------------------------- */
/* GTX format. */
/* -------------------------------------------------------------------- */
else if( strcmp(gi->format,"gtx") == 0 )
{
int words = gi->ct->lim.lam * gi->ct->lim.phi;
PAFile fid;
fid = pj_open_lib( ctx, gi->filename, "rb" );
if( fid == NULL )
{
pj_ctx_set_errno( ctx, -38 );
pj_release_lock();
return 0;
}
pj_ctx_fseek( ctx, fid, gi->grid_offset, SEEK_SET );
ct_tmp.cvs = (FLP *) pj_malloc(words*sizeof(float));
if( ct_tmp.cvs == NULL )
{
pj_ctx_set_errno( ctx, -38 );
pj_release_lock();
return 0;
}
if( pj_ctx_fread( ctx, ct_tmp.cvs, sizeof(float), words, fid )
!= (size_t)words )
{
pj_dalloc( ct_tmp.cvs );
pj_release_lock();
return 0;
}
if( IS_LSB )
swap_words( (unsigned char *) ct_tmp.cvs, 4, words );
pj_ctx_fclose( ctx, fid );
gi->ct->cvs = ct_tmp.cvs;
pj_release_lock();
return 1;
}
else
{
pj_release_lock();
return 0;
}
}
/************************************************************************/
/* pj_gridinfo_parent() */
/* */
/* Seek a parent grid file by name from a grid list */
/************************************************************************/
static PJ_GRIDINFO* pj_gridinfo_parent( PJ_GRIDINFO *gilist,
const char *name, int length )
{
while( gilist )
{
if( strncmp(gilist->ct->id,name,length) == 0 ) return gilist;
if( gilist->child )
{
PJ_GRIDINFO *parent=pj_gridinfo_parent( gilist->child, name, length );
if( parent ) return parent;
}
gilist=gilist->next;
}
return gilist;
}
/************************************************************************/
/* pj_gridinfo_init_ntv2() */
/* */
/* Load a ntv2 (.gsb) file. */
/************************************************************************/
static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist )
{
unsigned char header[11*16];
int num_subfiles, subfile;
int must_swap;
assert( sizeof(int) == 4 );
assert( sizeof(double) == 8 );
if( sizeof(int) != 4 || sizeof(double) != 8 )
{
pj_log( ctx, PJ_LOG_ERROR,
"basic types of inappropraiate size in pj_gridinfo_init_ntv2()" );
pj_ctx_set_errno( ctx, -38 );
return 0;
}
/* -------------------------------------------------------------------- */
/* Read the overview header. */
/* -------------------------------------------------------------------- */
if( pj_ctx_fread( ctx, header, sizeof(header), 1, fid ) != 1 )
{
pj_ctx_set_errno( ctx, -38 );
return 0;
}
if( header[8] == 11 )
must_swap = !IS_LSB;
else
must_swap = IS_LSB;
/* -------------------------------------------------------------------- */
/* Byte swap interesting fields if needed. */
/* -------------------------------------------------------------------- */
if( must_swap )
{
swap_words( header+8, 4, 1 );
swap_words( header+8+16, 4, 1 );
swap_words( header+8+32, 4, 1 );
swap_words( header+8+7*16, 8, 1 );
swap_words( header+8+8*16, 8, 1 );
swap_words( header+8+9*16, 8, 1 );
swap_words( header+8+10*16, 8, 1 );
}
/* -------------------------------------------------------------------- */
/* Get the subfile count out ... all we really use for now. */
/* -------------------------------------------------------------------- */
memcpy( &num_subfiles, header+8+32, 4 );
/* ==================================================================== */
/* Step through the subfiles, creating a PJ_GRIDINFO for each. */
/* ==================================================================== */
for( subfile = 0; subfile < num_subfiles; subfile++ )
{
struct CTABLE *ct;
LP ur;
int gs_count;
PJ_GRIDINFO *gi;
/* -------------------------------------------------------------------- */
/* Read header. */
/* -------------------------------------------------------------------- */
if( pj_ctx_fread( ctx, header, sizeof(header), 1, fid ) != 1 )
{
pj_ctx_set_errno( ctx, -38 );
return 0;
}
if( strncmp((const char *) header,"SUB_NAME",8) != 0 )
{
pj_ctx_set_errno( ctx, -38 );
return 0;
}
/* -------------------------------------------------------------------- */
/* Byte swap interesting fields if needed. */
/* -------------------------------------------------------------------- */
if( must_swap )
{
swap_words( header+8+16*4, 8, 1 );
swap_words( header+8+16*5, 8, 1 );
swap_words( header+8+16*6, 8, 1 );
swap_words( header+8+16*7, 8, 1 );
swap_words( header+8+16*8, 8, 1 );
swap_words( header+8+16*9, 8, 1 );
swap_words( header+8+16*10, 4, 1 );
}
/* -------------------------------------------------------------------- */
/* Initialize a corresponding "ct" structure. */
/* -------------------------------------------------------------------- */
ct = (struct CTABLE *) pj_malloc(sizeof(struct CTABLE));
strncpy( ct->id, (const char *) header + 8, 8 );
ct->id[8] = '\0';
ct->ll.lam = - *((double *) (header+7*16+8)); /* W_LONG */
ct->ll.phi = *((double *) (header+4*16+8)); /* S_LAT */
ur.lam = - *((double *) (header+6*16+8)); /* E_LONG */
ur.phi = *((double *) (header+5*16+8)); /* N_LAT */
ct->del.lam = *((double *) (header+9*16+8));
ct->del.phi = *((double *) (header+8*16+8));
ct->lim.lam = (int) (fabs(ur.lam-ct->ll.lam)/ct->del.lam + 0.5) + 1;
ct->lim.phi = (int) (fabs(ur.phi-ct->ll.phi)/ct->del.phi + 0.5) + 1;
pj_log( ctx, PJ_LOG_DEBUG_MINOR,
"NTv2 %s %dx%d: LL=(%.9g,%.9g) UR=(%.9g,%.9g)\n",
ct->id,
ct->lim.lam, ct->lim.phi,
ct->ll.lam/3600.0, ct->ll.phi/3600.0,
ur.lam/3600.0, ur.phi/3600.0 );
ct->ll.lam *= DEG_TO_RAD/3600.0;
ct->ll.phi *= DEG_TO_RAD/3600.0;
ct->del.lam *= DEG_TO_RAD/3600.0;
ct->del.phi *= DEG_TO_RAD/3600.0;
memcpy( &gs_count, header + 8 + 16*10, 4 );
if( gs_count != ct->lim.lam * ct->lim.phi )
{
pj_log( ctx, PJ_LOG_ERROR,
"GS_COUNT(%d) does not match expected cells (%dx%d=%d)\n",
gs_count, ct->lim.lam, ct->lim.phi,
ct->lim.lam * ct->lim.phi );
pj_ctx_set_errno( ctx, -38 );
return 0;
}
ct->cvs = NULL;
/* -------------------------------------------------------------------- */
/* Create a new gridinfo for this if we aren't processing the */
/* 1st subfile, and initialize our grid info. */
/* -------------------------------------------------------------------- */
if( subfile == 0 )
gi = gilist;
else
{
gi = (PJ_GRIDINFO *) pj_malloc(sizeof(PJ_GRIDINFO));
memset( gi, 0, sizeof(PJ_GRIDINFO) );
gi->gridname = strdup( gilist->gridname );
gi->filename = strdup( gilist->filename );
gi->next = NULL;
}
gi->must_swap = must_swap;
gi->ct = ct;
gi->format = "ntv2";
gi->grid_offset = pj_ctx_ftell( ctx, fid );
/* -------------------------------------------------------------------- */
/* Attach to the correct list or sublist. */
/* -------------------------------------------------------------------- */
if( strncmp((const char *)header+24,"NONE",4) == 0 )
{
if( gi != gilist )
{
PJ_GRIDINFO *lnk;
for( lnk = gilist; lnk->next != NULL; lnk = lnk->next ) {}
lnk->next = gi;
}
}
else
{
PJ_GRIDINFO *lnk;
PJ_GRIDINFO *gp = pj_gridinfo_parent(gilist,
(const char*)header+24,8);
if( gp == NULL )
{
pj_log( ctx, PJ_LOG_ERROR,
"pj_gridinfo_init_ntv2(): "
"failed to find parent %8.8s for %s.\n",
(const char *) header+24, gi->ct->id );
for( lnk = gilist; lnk->next != NULL; lnk = lnk->next ) {}
lnk->next = gi;
}
else
{
if( gp->child == NULL )
{
gp->child = gi;
}
else
{
for( lnk = gp->child; lnk->next != NULL; lnk = lnk->next ) {}
lnk->next = gi;
}
}
}
/* -------------------------------------------------------------------- */
/* Seek past the data. */
/* -------------------------------------------------------------------- */
pj_ctx_fseek( ctx, fid, gs_count * 16, SEEK_CUR );
}
return 1;
}
/************************************************************************/
/* pj_gridinfo_init_ntv1() */
/* */
/* Load an NTv1 style Canadian grid shift file. */
/************************************************************************/
static int pj_gridinfo_init_ntv1( projCtx ctx, PAFile fid, PJ_GRIDINFO *gi )
{
unsigned char header[176];
struct CTABLE *ct;
LP ur;
assert( sizeof(int) == 4 );
assert( sizeof(double) == 8 );
if( sizeof(int) != 4 || sizeof(double) != 8 )
{
pj_log( ctx, PJ_LOG_ERROR,
"basic types of inappropraiate size in nad_load_ntv1()" );
pj_ctx_set_errno( ctx, -38 );
return 0;
}
/* -------------------------------------------------------------------- */
/* Read the header. */
/* -------------------------------------------------------------------- */
if( pj_ctx_fread( ctx, header, sizeof(header), 1, fid ) != 1 )
{
pj_ctx_set_errno( ctx, -38 );
return 0;
}
/* -------------------------------------------------------------------- */
/* Regularize fields of interest. */
/* -------------------------------------------------------------------- */
if( IS_LSB )
{
swap_words( header+8, 4, 1 );
swap_words( header+24, 8, 1 );
swap_words( header+40, 8, 1 );
swap_words( header+56, 8, 1 );
swap_words( header+72, 8, 1 );
swap_words( header+88, 8, 1 );
swap_words( header+104, 8, 1 );
}
if( *((int *) (header+8)) != 12 )
{
pj_log( ctx, PJ_LOG_ERROR,
"NTv1 grid shift file has wrong record count, corrupt?" );
pj_ctx_set_errno( ctx, -38 );
return 0;
}
/* -------------------------------------------------------------------- */
/* Fill in CTABLE structure. */
/* -------------------------------------------------------------------- */
ct = (struct CTABLE *) pj_malloc(sizeof(struct CTABLE));
strcpy( ct->id, "NTv1 Grid Shift File" );
ct->ll.lam = - *((double *) (header+72));
ct->ll.phi = *((double *) (header+24));
ur.lam = - *((double *) (header+56));
ur.phi = *((double *) (header+40));
ct->del.lam = *((double *) (header+104));
ct->del.phi = *((double *) (header+88));
ct->lim.lam = (int) (fabs(ur.lam-ct->ll.lam)/ct->del.lam + 0.5) + 1;
ct->lim.phi = (int) (fabs(ur.phi-ct->ll.phi)/ct->del.phi + 0.5) + 1;
pj_log( ctx, PJ_LOG_DEBUG_MINOR,
"NTv1 %dx%d: LL=(%.9g,%.9g) UR=(%.9g,%.9g)",
ct->lim.lam, ct->lim.phi,
ct->ll.lam, ct->ll.phi, ur.lam, ur.phi );
ct->ll.lam *= DEG_TO_RAD;
ct->ll.phi *= DEG_TO_RAD;
ct->del.lam *= DEG_TO_RAD;
ct->del.phi *= DEG_TO_RAD;
ct->cvs = NULL;
gi->ct = ct;
gi->grid_offset = pj_ctx_ftell( ctx, fid );
gi->format = "ntv1";
return 1;
}
/************************************************************************/
/* pj_gridinfo_init_gtx() */
/* */
/* Load a NOAA .gtx vertical datum shift file. */
/************************************************************************/
static int pj_gridinfo_init_gtx( projCtx ctx, PAFile fid, PJ_GRIDINFO *gi )
{
unsigned char header[40];
struct CTABLE *ct;
double xorigin,yorigin,xstep,ystep;
int rows, columns;
assert( sizeof(int) == 4 );
assert( sizeof(double) == 8 );
if( sizeof(int) != 4 || sizeof(double) != 8 )
{
pj_log( ctx, PJ_LOG_ERROR,
"basic types of inappropraiate size in nad_load_gtx()" );
pj_ctx_set_errno( ctx, -38 );
return 0;
}
/* -------------------------------------------------------------------- */
/* Read the header. */
/* -------------------------------------------------------------------- */
if( pj_ctx_fread( ctx, header, sizeof(header), 1, fid ) != 1 )
{
pj_ctx_set_errno( ctx, -38 );
return 0;
}
/* -------------------------------------------------------------------- */
/* Regularize fields of interest and extract. */
/* -------------------------------------------------------------------- */
if( IS_LSB )
{
swap_words( header+0, 8, 4 );
swap_words( header+32, 4, 2 );
}
memcpy( &yorigin, header+0, 8 );
memcpy( &xorigin, header+8, 8 );
memcpy( &ystep, header+16, 8 );
memcpy( &xstep, header+24, 8 );
memcpy( &rows, header+32, 4 );
memcpy( &columns, header+36, 4 );
if( xorigin < -360 || xorigin > 360
|| yorigin < -90 || yorigin > 90 )
{
pj_log( ctx, PJ_LOG_ERROR,
"gtx file header has invalid extents, corrupt?");
pj_ctx_set_errno( ctx, -38 );
return 0;
}
/* -------------------------------------------------------------------- */
/* Fill in CTABLE structure. */
/* -------------------------------------------------------------------- */
ct = (struct CTABLE *) pj_malloc(sizeof(struct CTABLE));
strcpy( ct->id, "GTX Vertical Grid Shift File" );
ct->ll.lam = xorigin;
ct->ll.phi = yorigin;
ct->del.lam = xstep;
ct->del.phi = ystep;
ct->lim.lam = columns;
ct->lim.phi = rows;
/* some GTX files come in 0-360 and we shift them back into the
expected -180 to 180 range if possible. This does not solve
problems with grids spanning the dateline. */
if( ct->ll.lam >= 180.0 )
ct->ll.lam -= 360.0;
if( ct->ll.lam >= 0.0 && ct->ll.lam + ct->del.lam * ct->lim.lam > 180.0 )
{
pj_log( ctx, PJ_LOG_DEBUG_MAJOR,
"This GTX spans the dateline! This will cause problems." );
}
pj_log( ctx, PJ_LOG_DEBUG_MINOR,
"GTX %dx%d: LL=(%.9g,%.9g) UR=(%.9g,%.9g)",
ct->lim.lam, ct->lim.phi,
ct->ll.lam, ct->ll.phi,
ct->ll.lam + (columns-1)*xstep, ct->ll.phi + (rows-1)*ystep);
ct->ll.lam *= DEG_TO_RAD;
ct->ll.phi *= DEG_TO_RAD;
ct->del.lam *= DEG_TO_RAD;
ct->del.phi *= DEG_TO_RAD;
ct->cvs = NULL;
gi->ct = ct;
gi->grid_offset = 40;
gi->format = "gtx";
return 1;
}
/************************************************************************/
/* pj_gridinfo_init() */
/* */
/* Open and parse header details from a datum gridshift file */
/* returning a list of PJ_GRIDINFOs for the grids in that */
/* file. This superceeds use of nad_init() for modern */
/* applications. */
/************************************************************************/
PJ_GRIDINFO *pj_gridinfo_init( projCtx ctx, const char *gridname )
{
char fname[MAX_PATH_FILENAME+1];
PJ_GRIDINFO *gilist;
PAFile fp;
char header[160];
errno = pj_errno = 0;
ctx->last_errno = 0;
/* -------------------------------------------------------------------- */
/* Initialize a GRIDINFO with stub info we would use if it */
/* cannot be loaded. */
/* -------------------------------------------------------------------- */
gilist = (PJ_GRIDINFO *) pj_malloc(sizeof(PJ_GRIDINFO));
memset( gilist, 0, sizeof(PJ_GRIDINFO) );
gilist->gridname = strdup( gridname );
gilist->filename = NULL;
gilist->format = "missing";
gilist->grid_offset = 0;
gilist->ct = NULL;
gilist->next = NULL;
/* -------------------------------------------------------------------- */
/* Open the file using the usual search rules. */
/* -------------------------------------------------------------------- */
strcpy(fname, gridname);
if (!(fp = pj_open_lib(ctx, fname, "rb"))) {
ctx->last_errno = 0; /* don't treat as a persistent error */
return gilist;
}
gilist->filename = strdup(fname);
/* -------------------------------------------------------------------- */
/* Load a header, to determine the file type. */
/* -------------------------------------------------------------------- */
if( pj_ctx_fread( ctx, header, sizeof(header), 1, fp ) != 1 )
{
/* some files may be smaller that sizeof(header), eg 160, so */
ctx->last_errno = 0; /* don't treat as a persistent error */
}
pj_ctx_fseek( ctx, fp, SEEK_SET, 0 );
/* -------------------------------------------------------------------- */
/* Determine file type. */
/* -------------------------------------------------------------------- */
if( strncmp(header + 0, "HEADER", 6) == 0
&& strncmp(header + 96, "W GRID", 6) == 0
&& strncmp(header + 144, "TO NAD83 ", 16) == 0 )
{
pj_gridinfo_init_ntv1( ctx, fp, gilist );
}
else if( strncmp(header + 0, "NUM_OREC", 8) == 0
&& strncmp(header + 48, "GS_TYPE", 7) == 0 )
{
pj_gridinfo_init_ntv2( ctx, fp, gilist );
}
else if( strlen(gridname) > 4
&& (strcmp(gridname+strlen(gridname)-3,"gtx") == 0
|| strcmp(gridname+strlen(gridname)-3,"GTX") == 0) )
{
pj_gridinfo_init_gtx( ctx, fp, gilist );
}
else if( strncmp(header + 0,"CTABLE V2",9) == 0 )
{
struct CTABLE *ct = nad_ctable2_init( ctx, fp );
gilist->format = "ctable2";
gilist->ct = ct;
pj_log( ctx, PJ_LOG_DEBUG_MAJOR,
"Ctable2 %s %dx%d: LL=(%.9g,%.9g) UR=(%.9g,%.9g)\n",
ct->id,
ct->lim.lam, ct->lim.phi,
ct->ll.lam * RAD_TO_DEG, ct->ll.phi * RAD_TO_DEG,
(ct->ll.lam + (ct->lim.lam-1)*ct->del.lam) * RAD_TO_DEG,
(ct->ll.phi + (ct->lim.phi-1)*ct->del.phi) * RAD_TO_DEG );
}
else
{
struct CTABLE *ct = nad_ctable_init( ctx, fp );
if (ct == NULL)
{
pj_log( ctx, PJ_LOG_DEBUG_MAJOR,
"CTABLE ct is NULL.");
} else
{
gilist->format = "ctable";
gilist->ct = ct;
pj_log( ctx, PJ_LOG_DEBUG_MAJOR,
"Ctable %s %dx%d: LL=(%.9g,%.9g) UR=(%.9g,%.9g)\n",
ct->id,
ct->lim.lam, ct->lim.phi,
ct->ll.lam * RAD_TO_DEG, ct->ll.phi * RAD_TO_DEG,
(ct->ll.lam + (ct->lim.lam-1)*ct->del.lam) * RAD_TO_DEG,
(ct->ll.phi + (ct->lim.phi-1)*ct->del.phi) * RAD_TO_DEG );
}
}
pj_ctx_fclose(ctx, fp);
return gilist;
}
proj-4.9.3/src/pj_param.c 0000644 0000000 0000000 00000006022 12761101536 012116 0000000 0000000 /* put parameters in linked list and retrieve */
#include
#include
#include
paralist * /* create parameter list entry */
pj_mkparam(char *str) {
paralist *newitem;
if((newitem = (paralist *)pj_malloc(sizeof(paralist) + strlen(str))) != NULL) {
newitem->used = 0;
newitem->next = 0;
if (*str == '+')
++str;
(void)strcpy(newitem->param, str);
}
return newitem;
}
/************************************************************************/
/* pj_param() */
/* */
/* Test for presence or get parameter value. The first */
/* character in `opt' is a parameter type which can take the */
/* values: */
/* */
/* `t' - test for presence, return TRUE/FALSE in PROJVALUE.i */
/* `i' - integer value returned in PROJVALUE.i */
/* `d' - simple valued real input returned in PROJVALUE.f */
/* `r' - degrees (DMS translation applied), returned as */
/* radians in PROJVALUE.f */
/* `s' - string returned in PROJVALUE.s */
/* `b' - test for t/T/f/F, return in PROJVALUE.i */
/* */
/************************************************************************/
PROJVALUE /* test for presence or get parameter value */
pj_param(projCtx ctx, paralist *pl, const char *opt) {
int type;
unsigned l;
PROJVALUE value;
if( ctx == NULL )
ctx = pj_get_default_ctx();
type = *opt++;
/* simple linear lookup */
l = strlen(opt);
while (pl && !(!strncmp(pl->param, opt, l) &&
(!pl->param[l] || pl->param[l] == '=')))
pl = pl->next;
if (type == 't')
value.i = pl != 0;
else if (pl) {
pl->used |= 1;
opt = pl->param + l;
if (*opt == '=')
++opt;
switch (type) {
case 'i': /* integer input */
value.i = atoi(opt);
break;
case 'd': /* simple real input */
value.f = pj_atof(opt);
break;
case 'r': /* degrees input */
value.f = dmstor_ctx(ctx, opt, 0);
break;
case 's': /* char string */
value.s = (char *) opt;
break;
case 'b': /* boolean */
switch (*opt) {
case 'F': case 'f':
value.i = 0;
break;
case '\0': case 'T': case 't':
value.i = 1;
break;
default:
pj_ctx_set_errno(ctx, -8);
value.i = 0;
break;
}
break;
default:
bum_type: /* note: this is an error in parameter, not a user error */
fprintf(stderr, "invalid request to pj_param, fatal\n");
exit(1);
}
} else /* not given */
switch (type) {
case 'b':
case 'i':
value.i = 0;
break;
case 'd':
case 'r':
value.f = 0.;
break;
case 's':
value.s = 0;
break;
default:
goto bum_type;
}
return value;
}
proj-4.9.3/src/PJ_merc.c 0000644 0000000 0000000 00000006646 12761101536 011660 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(merc, "Mercator") "\n\tCyl, Sph&Ell\n\tlat_ts=";
#define EPS10 1.e-10
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
if (fabs(fabs(lp.phi) - M_HALFPI) <= EPS10)
F_ERROR;
xy.x = P->k0 * lp.lam;
xy.y = - P->k0 * log(pj_tsfn(lp.phi, sin(lp.phi), P->e));
return xy;
}
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
if (fabs(fabs(lp.phi) - M_HALFPI) <= EPS10)
F_ERROR;
xy.x = P->k0 * lp.lam;
xy.y = P->k0 * log(tan(M_FORTPI + .5 * lp.phi));
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
if ((lp.phi = pj_phi2(P->ctx, exp(- xy.y / P->k0), P->e)) == HUGE_VAL)
I_ERROR;
lp.lam = xy.x / P->k0;
return lp;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
lp.phi = M_HALFPI - 2. * atan(exp(-xy.y / P->k0));
lp.lam = xy.x / P->k0;
return lp;
}
static void freeup(PJ *P) { /* Destructor */
pj_dealloc(P);
}
PJ *PROJECTION(merc) {
double phits=0.0;
int is_phits;
if( (is_phits = pj_param(P->ctx, P->params, "tlat_ts").i) ) {
phits = fabs(pj_param(P->ctx, P->params, "rlat_ts").f);
if (phits >= M_HALFPI) E_ERROR(-24);
}
if (P->es) { /* ellipsoid */
if (is_phits)
P->k0 = pj_msfn(sin(phits), cos(phits), P->es);
P->inv = e_inverse;
P->fwd = e_forward;
}
else { /* sphere */
if (is_phits)
P->k0 = cos(phits);
P->inv = s_inverse;
P->fwd = s_forward;
}
return P;
}
#ifndef PJ_SELFTEST
int pj_merc_selftest (void) {return 0;}
#else
int pj_merc_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=merc +ellps=GRS80 +lat_1=0.5 +lat_2=2"};
char s_args[] = {"+proj=merc +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222638.981586547132, 110579.965218249708},
{ 222638.981586547132, -110579.965218249112},
{-222638.981586547132, 110579.965218249708},
{-222638.981586547132, -110579.965218249112},
};
XY s_fwd_expect[] = {
{ 223402.144255274179, 111706.743574944077},
{ 223402.144255274179, -111706.743574944485},
{-223402.144255274179, 111706.743574944077},
{-223402.144255274179, -111706.743574944485},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.00179663056823904264, 0.00090436947522799056},
{ 0.00179663056823904264, -0.00090436947522799056},
{-0.00179663056823904264, 0.00090436947522799056},
{-0.00179663056823904264, -0.00090436947522799056},
};
LP s_inv_expect[] = {
{ 0.00179049310978382265, 0.000895246554845297135},
{ 0.00179049310978382265, -0.000895246554858019272},
{-0.00179049310978382265, 0.000895246554845297135},
{-0.00179049310978382265, -0.000895246554858019272},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_nell.c 0000644 0000000 0000000 00000004322 12761101536 011651 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(nell, "Nell") "\n\tPCyl., Sph.";
#define MAX_ITER 10
#define LOOP_TOL 1e-7
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
double k, V;
int i;
(void) P;
k = 2. * sin(lp.phi);
V = lp.phi * lp.phi;
lp.phi *= 1.00371 + V * (-0.0935382 + V * -0.011412);
for (i = MAX_ITER; i ; --i) {
lp.phi -= V = (lp.phi + sin(lp.phi) - k) /
(1. + cos(lp.phi));
if (fabs(V) < LOOP_TOL)
break;
}
xy.x = 0.5 * lp.lam * (1. + cos(lp.phi));
xy.y = lp.phi;
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
lp.lam = 2. * xy.x / (1. + cos(xy.y));
lp.phi = aasin(P->ctx,0.5 * (xy.y + sin(xy.y)));
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(nell) {
P->es = 0;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_nell_selftest (void) {return 0;}
#else
int pj_nell_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=nell +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223385.132504695706, 111698.23644718733},
{ 223385.132504695706, -111698.23644718733},
{-223385.132504695706, 111698.23644718733},
{-223385.132504695706, -111698.23644718733},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00179049310989310567, 0.000895246554910125161},
{ 0.00179049310989310567, -0.000895246554910125161},
{-0.00179049310989310567, 0.000895246554910125161},
{-0.00179049310989310567, -0.000895246554910125161},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_boggs.c 0000644 0000000 0000000 00000003245 12761101536 012023 0000000 0000000 #define PJ_LIB__
# include
PROJ_HEAD(boggs, "Boggs Eumorphic") "\n\tPCyl., no inv., Sph.";
# define NITER 20
# define EPS 1e-7
# define ONETOL 1.000001
# define FXC 2.00276
# define FXC2 1.11072
# define FYC 0.49931
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
double theta, th1, c;
int i;
(void) P;
theta = lp.phi;
if (fabs(fabs(lp.phi) - M_HALFPI) < EPS)
xy.x = 0.;
else {
c = sin(theta) * M_PI;
for (i = NITER; i; --i) {
theta -= th1 = (theta + sin(theta) - c) /
(1. + cos(theta));
if (fabs(th1) < EPS) break;
}
theta *= 0.5;
xy.x = FXC * lp.lam / (1. / cos(lp.phi) + FXC2 / cos(theta));
}
xy.y = FYC * (lp.phi + M_SQRT2 * sin(theta));
return (xy);
}
static void *freeup_new (PJ *P) { /* Destructor */
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(boggs) {
P->es = 0.;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_boggs_selftest (void) {return 0;}
#else
int pj_boggs_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=boggs +a=6400000 +lat_1=0 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 211949.70080818201, 117720.99830541089},
{ 211949.70080818201, -117720.99830541089},
{-211949.70080818201, 117720.99830541089},
{-211949.70080818201, -117720.99830541089},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 0, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/PJ_wink1.c 0000644 0000000 0000000 00000004233 12761101536 011751 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(wink1, "Winkel I") "\n\tPCyl., Sph.\n\tlat_ts=";
struct pj_opaque {
double cosphi1;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
xy.x = .5 * lp.lam * (P->opaque->cosphi1 + cos(lp.phi));
xy.y = lp.phi;
return (xy);
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
lp.phi = xy.y;
lp.lam = 2. * xy.x / (P->opaque->cosphi1 + cos(lp.phi));
return (lp);
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(wink1) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
P->opaque->cosphi1 = cos (pj_param(P->ctx, P->params, "rlat_ts").f);
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_wink1_selftest (void) {return 0;}
#else
int pj_wink1_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=wink1 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223385.13164095284, 111701.07212763709},
{ 223385.13164095284, -111701.07212763709},
{-223385.13164095284, 111701.07212763709},
{-223385.13164095284, -111701.07212763709},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0017904931098931057, 0.00089524655489191132},
{ 0.0017904931098931057, -0.00089524655489191132},
{-0.0017904931098931057, 0.00089524655489191132},
{-0.0017904931098931057, -0.00089524655489191132},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_eck2.c 0000644 0000000 0000000 00000004446 12761101536 011552 0000000 0000000 #define PJ_LIB__
# include
PROJ_HEAD(eck2, "Eckert II") "\n\tPCyl. Sph.";
#define FXC 0.46065886596178063902
#define FYC 1.44720250911653531871
#define C13 0.33333333333333333333
#define ONEEPS 1.0000001
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
(void) P;
xy.x = FXC * lp.lam * (xy.y = sqrt(4. - 3. * sin(fabs(lp.phi))));
xy.y = FYC * (2. - xy.y);
if ( lp.phi < 0.) xy.y = -xy.y;
return (xy);
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
(void) P;
lp.lam = xy.x / (FXC * ( lp.phi = 2. - fabs(xy.y) / FYC) );
lp.phi = (4. - lp.phi * lp.phi) * C13;
if (fabs(lp.phi) >= 1.) {
if (fabs(lp.phi) > ONEEPS) I_ERROR
else
lp.phi = lp.phi < 0. ? -M_HALFPI : M_HALFPI;
} else
lp.phi = asin(lp.phi);
if (xy.y < 0)
lp.phi = -lp.phi;
return (lp);
}
static void *freeup_new (PJ *P) { /* Destructor */
return pj_dealloc (P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(eck2) {
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_eck2_selftest (void) {return 0;}
#else
int pj_eck2_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=eck2 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 204472.87090796008, 121633.73497524235},
{ 204472.87090796008, -121633.73497524235},
{-204472.87090796008, 121633.73497524235},
{-204472.87090796008, -121633.73497524235},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0019434150820034624, 0.00082480429919795412},
{ 0.0019434150820034624, -0.00082480429919795412},
{-0.0019434150820034624, 0.00082480429919795412},
{-0.0019434150820034624, -0.00082480429919795412},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_mod_ster.c 0000644 0000000 0000000 00000032722 12761101536 012540 0000000 0000000 /* based upon Snyder and Linck, USGS-NMD */
#define PJ_LIB__
#include
PROJ_HEAD(mil_os, "Miller Oblated Stereographic") "\n\tAzi(mod)";
PROJ_HEAD(lee_os, "Lee Oblated Stereographic") "\n\tAzi(mod)";
PROJ_HEAD(gs48, "Mod. Stereographic of 48 U.S.") "\n\tAzi(mod)";
PROJ_HEAD(alsk, "Mod. Stereographic of Alaska") "\n\tAzi(mod)";
PROJ_HEAD(gs50, "Mod. Stereographic of 50 U.S.") "\n\tAzi(mod)";
#define EPSLN 1e-12
struct pj_opaque {
COMPLEX *zcoeff; \
double cchio, schio; \
int n;
};
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double sinlon, coslon, esphi, chi, schi, cchi, s;
COMPLEX p;
sinlon = sin(lp.lam);
coslon = cos(lp.lam);
esphi = P->e * sin(lp.phi);
chi = 2. * atan(tan((M_HALFPI + lp.phi) * .5) *
pow((1. - esphi) / (1. + esphi), P->e * .5)) - M_HALFPI;
schi = sin(chi);
cchi = cos(chi);
s = 2. / (1. + Q->schio * schi + Q->cchio * cchi * coslon);
p.r = s * cchi * sinlon;
p.i = s * (Q->cchio * schi - Q->schio * cchi * coslon);
p = pj_zpoly1(p, Q->zcoeff, Q->n);
xy.x = p.r;
xy.y = p.i;
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
int nn;
COMPLEX p, fxy, fpxy, dp;
double den, rh, z, sinz, cosz, chi, phi, dphi, esphi;
p.r = xy.x;
p.i = xy.y;
for (nn = 20; nn ;--nn) {
fxy = pj_zpolyd1(p, Q->zcoeff, Q->n, &fpxy);
fxy.r -= xy.x;
fxy.i -= xy.y;
den = fpxy.r * fpxy.r + fpxy.i * fpxy.i;
dp.r = -(fxy.r * fpxy.r + fxy.i * fpxy.i) / den;
dp.i = -(fxy.i * fpxy.r - fxy.r * fpxy.i) / den;
p.r += dp.r;
p.i += dp.i;
if ((fabs(dp.r) + fabs(dp.i)) <= EPSLN)
break;
}
if (nn) {
rh = hypot(p.r, p.i);
z = 2. * atan(.5 * rh);
sinz = sin(z);
cosz = cos(z);
lp.lam = P->lam0;
if (fabs(rh) <= EPSLN) {
lp.phi = P->phi0;
return lp;
}
chi = aasin(P->ctx, cosz * Q->schio + p.i * sinz * Q->cchio / rh);
phi = chi;
for (nn = 20; nn ;--nn) {
esphi = P->e * sin(phi);
dphi = 2. * atan(tan((M_HALFPI + chi) * .5) *
pow((1. + esphi) / (1. - esphi), P->e * .5)) - M_HALFPI - phi;
phi += dphi;
if (fabs(dphi) <= EPSLN)
break;
}
}
if (nn) {
lp.phi = phi;
lp.lam = atan2(p.r * sinz, rh * Q->cchio * cosz - p.i *
Q->schio * sinz);
} else
lp.lam = lp.phi = HUGE_VAL;
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
static PJ *setup(PJ *P) { /* general initialization */
struct pj_opaque *Q = P->opaque;
double esphi, chio;
if (P->es) {
esphi = P->e * sin(P->phi0);
chio = 2. * atan(tan((M_HALFPI + P->phi0) * .5) *
pow((1. - esphi) / (1. + esphi), P->e * .5)) - M_HALFPI;
} else
chio = P->phi0;
Q->schio = sin(chio);
Q->cchio = cos(chio);
P->inv = e_inverse;
P->fwd = e_forward;
return P;
}
/* Miller Oblated Stereographic */
PJ *PROJECTION(mil_os) {
static COMPLEX AB[] = {
{0.924500, 0.},
{0., 0.},
{0.019430, 0.}
};
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->n = 2;
P->lam0 = DEG_TO_RAD * 20.;
P->phi0 = DEG_TO_RAD * 18.;
Q->zcoeff = AB;
P->es = 0.;
return setup(P);
}
/* Lee Oblated Stereographic */
PJ *PROJECTION(lee_os) {
static COMPLEX AB[] = {
{0.721316, 0.},
{0., 0.},
{-0.0088162, -0.00617325}
};
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->n = 2;
P->lam0 = DEG_TO_RAD * -165.;
P->phi0 = DEG_TO_RAD * -10.;
Q->zcoeff = AB;
P->es = 0.;
return setup(P);
}
PJ *PROJECTION(gs48) {
static COMPLEX /* 48 United States */
AB[] = {
{0.98879, 0.},
{0., 0.},
{-0.050909, 0.},
{0., 0.},
{0.075528, 0.}
};
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->n = 4;
P->lam0 = DEG_TO_RAD * -96.;
P->phi0 = DEG_TO_RAD * -39.;
Q->zcoeff = AB;
P->es = 0.;
P->a = 6370997.;
return setup(P);
}
PJ *PROJECTION(alsk) {
static COMPLEX ABe[] = { /* Alaska ellipsoid */
{ .9945303, 0.},
{ .0052083, -.0027404},
{ .0072721, .0048181},
{-.0151089, -.1932526},
{ .0642675, -.1381226},
{ .3582802, -.2884586},
};
static COMPLEX ABs[] = { /* Alaska sphere */
{ .9972523, 0.},
{ .0052513, -.0041175},
{ .0074606, .0048125},
{-.0153783, -.1968253},
{ .0636871, -.1408027},
{ .3660976, -.2937382}
};
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->n = 5;
P->lam0 = DEG_TO_RAD * -152.;
P->phi0 = DEG_TO_RAD * 64.;
if (P->es) { /* fixed ellipsoid/sphere */
Q->zcoeff = ABe;
P->a = 6378206.4;
P->e = sqrt(P->es = 0.00676866);
} else {
Q->zcoeff = ABs;
P->a = 6370997.;
}
return setup(P);
}
PJ *PROJECTION(gs50) {
static COMPLEX ABe[] = { /* GS50 ellipsoid */
{ .9827497, 0.},
{ .0210669, .0053804},
{-.1031415, -.0571664},
{-.0323337, -.0322847},
{ .0502303, .1211983},
{ .0251805, .0895678},
{-.0012315, -.1416121},
{ .0072202, -.1317091},
{-.0194029, .0759677},
{-.0210072, .0834037}
};
static COMPLEX ABs[] = { /* GS50 sphere */
{ .9842990, 0.},
{ .0211642, .0037608},
{-.1036018, -.0575102},
{-.0329095, -.0320119},
{ .0499471, .1223335},
{ .0260460, .0899805},
{ .0007388, -.1435792},
{ .0075848, -.1334108},
{-.0216473, .0776645},
{-.0225161, .0853673}
};
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->n = 9;
P->lam0 = DEG_TO_RAD * -120.;
P->phi0 = DEG_TO_RAD * 45.;
if (P->es) { /* fixed ellipsoid/sphere */
Q->zcoeff = ABe;
P->a = 6378206.4;
P->e = sqrt(P->es = 0.00676866);
} else {
Q->zcoeff = ABs;
P->a = 6370997.;
}
return setup(P);
}
#ifndef PJ_SELFTEST
int pj_mil_os_selftest (void) {return 0;}
#else
int pj_mil_os_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=mil_os +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{-1908527.94959420455, -1726237.4730614475},
{-1916673.02291848511, -1943133.88812552323},
{-2344429.41208962305, -1706258.05121891224},
{-2354637.83553299867, -1926468.60513541684},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{20.0020363939492398, 18.0009683469140498},
{20.0020363715837419, 17.999031631815086},
{19.9979636060507602, 18.0009683469140498},
{19.9979636284162581, 17.999031631815086},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_lee_os_selftest (void) {return 0;}
#else
int pj_lee_os_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=lee_os +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{-25564478.9526050538, 154490848.8286255},
{ 30115393.9385746419, 125193997.439701974},
{-31039340.5921660066, 57678685.0448915437},
{-3088419.93942357088, 58150091.0991110131},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{-164.997479457813824, -9.99875886103541411},
{-164.997479438558884, -10.0012411200022751},
{-165.002520542186289, -9.99875886103545142},
{-165.002520561440946, -10.0012411200022999},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_gs48_selftest (void) {return 0;}
#else
int pj_gs48_selftest (void) {
double tolerance_lp = 1e-12;
double tolerance_xy = 1e-8;
char s_args[] = {"+proj=gs48 +a=6370997"};
/* All latitudes and longitudes within the continental US */
LP fwd_in[] = {
{ -119.0, 40.0},
{ -70.0, 64.0},
{ -80.0, 25.0},
{ -95.0, 35.0}
};
XY s_fwd_expect[] = {
{-12110635.970867658000, 11668127.145744404000},
{ 55440975.381938063000, 52147696.705027729000},
{ 4451809.270766614000, 8613528.123849634100},
{ 468857.625827528540, 14336668.749030361000},
};
XY inv_in[] = {
{-11980000.0, 11570000.0},
{ 5500000.0, 52000000.0},
{ 4400000.0, 8600000.0},
{ 460000.0, 14000000.0},
};
LP s_inv_expect[] = {
{-119.003821215898, 39.801671381755},
{ -92.805621432558, 59.836947814918},
{ -80.122548940303, 24.869675983950},
{ -94.990474496482, 34.401182359832},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_alsk_selftest (void) {return 0;}
#else
int pj_alsk_selftest (void) {
/* The standard test points are way outside the definition area bounds, hence we relax tolerances */
double tolerance_lp = 1e-12;
double tolerance_xy = 1e-8;
char e_args[] = {"+proj=alsk +ellps=clrk66"};
char s_args[] = {"+proj=alsk +a=6370997"};
LP fwd_in[] = {
{-160.0, 55.0},
{-160.0, 70.0},
{-145.0, 70.0},
{-145.0, 60.0}
};
XY e_fwd_expect[] = {
{-513253.146950842060, -968928.031867943470},
{-305001.133897637190, 687494.464958650530},
{266454.305088600490, 683423.477493030950},
{389141.322439243960, -423913.251230396680},
};
XY s_fwd_expect[] = {
{-511510.319410844070, -967150.991676078060},
{-303744.771290368980, 685439.745941123230},
{265354.974019662940, 681386.892874573010},
{387711.995394026630, -422980.685505462640},
};
XY inv_in[] = {
{-500000.0, -950000.0},
{-305000.0, 700000.0},
{ 250000.0, 700000.0},
{ 400000.0, -400000.0}
};
LP e_inv_expect[] = {
{-159.830804302926, 55.183195262220},
{-160.042203155537, 70.111086864056},
{-145.381043551466, 70.163900908411},
{-144.758985461448, 60.202929200739},
};
LP s_inv_expect[] = {
{-159.854014457557, 55.165653849074},
{-160.082332371601, 70.128307617632},
{-145.347827407243, 70.181566919011},
{-144.734239827146, 60.193564732505},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_gs50_selftest (void) {return 0;}
#else
int pj_gs50_selftest (void) {
double tolerance_lp = 1e-12;
double tolerance_xy = 1e-8;
char e_args[] = {"+proj=gs50 +ellps=clrk66"};
char s_args[] = {"+proj=gs50 +a=6370997"};
LP fwd_in[] = {
{-160.0, 65.0},
{-130.0, 45.0},
{ -65.0, 45.0},
{ -80.0, 36.0},
};
XY e_fwd_expect[] = {
{-1874628.5377402329, 2660907.942291015300},
{ -771831.51885333552, 48465.166491304852},
{ 4030931.8339815089, 1323687.864777399200},
{ 3450764.2615361013, -175619.041820732440},
};
XY s_fwd_expect[] = {
{-1867268.2534600089, 2656506.230401823300},
{ -769572.18967299373, 48324.312440863941},
{ 4019393.068680791200, 1320191.309350289200},
{ 3442685.615172345700, -178760.423489428680},
};
XY inv_in[] = {
{-1800000.0, 2600000.0},
{ -800000.0, 500000.0},
{ 4000000.0, 1300000.0},
{ 3900000.0, -170000.0},
};
LP e_inv_expect[] = {
{-157.989284999679, 64.851559609698},
{-131.171390466814, 49.084969745967},
{ -65.491568685301, 44.992837923774},
{ -75.550660091101, 34.191114075743},
};
LP s_inv_expect[] = {
{-158.163295044933, 64.854288364994},
{-131.206816959506, 49.082915350974},
{ -65.348945220767, 44.957292681774},
{ -75.446820242089, 34.185406225616},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_wag2.c 0000644 0000000 0000000 00000003713 12761101536 011562 0000000 0000000 #define PJ_LIB__
# include
PROJ_HEAD(wag2, "Wagner II") "\n\tPCyl., Sph.";
#define C_x 0.92483
#define C_y 1.38725
#define C_p1 0.88022
#define C_p2 0.88550
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
lp.phi = aasin (P->ctx,C_p1 * sin (C_p2 * lp.phi));
xy.x = C_x * lp.lam * cos (lp.phi);
xy.y = C_y * lp.phi;
return (xy);
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
lp.phi = xy.y / C_y;
lp.lam = xy.x / (C_x * cos(lp.phi));
lp.phi = aasin (P->ctx,sin(lp.phi) / C_p1) / C_p2;
return (lp);
}
static void *freeup_new (PJ *P) { /* Destructor */
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(wag2) {
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_wag2_selftest (void) {return 0;}
#else
int pj_wag2_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=wag2 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 206589.88809996162, 120778.04035754716},
{ 206589.88809996162, -120778.04035754716},
{-206589.88809996162, 120778.04035754716},
{-206589.88809996162, -120778.04035754716},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0019360240367390709, 0.00082795765763814082},
{ 0.0019360240367390709, -0.00082795765763814082},
{-0.0019360240367390709, 0.00082795765763814082},
{-0.0019360240367390709, -0.00082795765763814082},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_mbtfpq.c 0000644 0000000 0000000 00000005601 12761101536 012211 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(mbtfpq, "McBryde-Thomas Flat-Polar Quartic") "\n\tCyl., Sph.";
#define NITER 20
#define EPS 1e-7
#define ONETOL 1.000001
#define C 1.70710678118654752440
#define RC 0.58578643762690495119
#define FYC 1.87475828462269495505
#define RYC 0.53340209679417701685
#define FXC 0.31245971410378249250
#define RXC 3.20041258076506210122
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
double th1, c;
int i;
(void) P;
c = C * sin(lp.phi);
for (i = NITER; i; --i) {
lp.phi -= th1 = (sin(.5*lp.phi) + sin(lp.phi) - c) /
(.5*cos(.5*lp.phi) + cos(lp.phi));
if (fabs(th1) < EPS) break;
}
xy.x = FXC * lp.lam * (1.0 + 2. * cos(lp.phi)/cos(0.5 * lp.phi));
xy.y = FYC * sin(0.5 * lp.phi);
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
double t;
lp.phi = RYC * xy.y;
if (fabs(lp.phi) > 1.) {
if (fabs(lp.phi) > ONETOL) I_ERROR
else if (lp.phi < 0.) { t = -1.; lp.phi = -M_PI; }
else { t = 1.; lp.phi = M_PI; }
} else
lp.phi = 2. * asin(t = lp.phi);
lp.lam = RXC * xy.x / (1. + 2. * cos(lp.phi)/cos(0.5 * lp.phi));
lp.phi = RC * (t + sin(lp.phi));
if (fabs(lp.phi) > 1.)
if (fabs(lp.phi) > ONETOL) I_ERROR
else lp.phi = lp.phi < 0. ? -M_HALFPI : M_HALFPI;
else
lp.phi = asin(lp.phi);
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(mbtfpq) {
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_mbtfpq_selftest (void) {return 0;}
#else
int pj_mbtfpq_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=mbtfpq +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 209391.854738393013, 119161.040199054827},
{ 209391.854738393013, -119161.040199054827},
{-209391.854738393013, 119161.040199054827},
{-209391.854738393013, -119161.040199054827},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00191010555824111571, 0.000839185447792341723},
{ 0.00191010555824111571, -0.000839185447792341723},
{-0.00191010555824111571, 0.000839185447792341723},
{-0.00191010555824111571, -0.000839185447792341723},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/Makefile.am 0000644 0000000 0000000 00000006323 12761101536 012221 0000000 0000000 AM_CFLAGS = @C_WFLAGS@
bin_PROGRAMS = proj nad2bin geod cs2cs
EXTRA_PROGRAMS = multistresstest test228
AM_CPPFLAGS = -DPROJ_LIB=\"$(pkgdatadir)\" \
-DMUTEX_@MUTEX_SETTING@ @JNI_INCLUDE@
include_HEADERS = proj_api.h projects.h geodesic.h \
org_proj4_Projections.h org_proj4_PJ.h
EXTRA_DIST = makefile.vc proj.def bin_cs2cs.cmake \
bin_geod.cmake bin_nad2bin.cmake bin_proj.cmake \
lib_proj.cmake CMakeLists.txt bin_geodtest.cmake geodtest.c
proj_SOURCES = proj.c gen_cheb.c p_series.c
cs2cs_SOURCES = cs2cs.c gen_cheb.c p_series.c
nad2bin_SOURCES = nad2bin.c
geod_SOURCES = geod.c geod_set.c geod_interface.c geod_interface.h
multistresstest_SOURCES = multistresstest.c
test228_SOURCES = test228.c
proj_LDADD = libproj.la
cs2cs_LDADD = libproj.la
nad2bin_LDADD = libproj.la
geod_LDADD = libproj.la
multistresstest_LDADD = libproj.la @THREAD_LIB@
test228_LDADD = libproj.la @THREAD_LIB@
lib_LTLIBRARIES = libproj.la
libproj_la_LDFLAGS = -no-undefined -version-info 12:0:0
libproj_la_SOURCES = \
pj_list.h \
PJ_aeqd.c PJ_gnom.c PJ_laea.c PJ_mod_ster.c \
PJ_nsper.c PJ_nzmg.c PJ_ortho.c PJ_stere.c PJ_sterea.c \
PJ_aea.c PJ_bipc.c PJ_bonne.c PJ_eqdc.c PJ_isea.c \
PJ_imw_p.c PJ_krovak.c PJ_lcc.c PJ_poly.c \
PJ_rpoly.c PJ_sconics.c proj_rouss.c \
PJ_cass.c PJ_cc.c PJ_cea.c PJ_eqc.c \
PJ_gall.c PJ_labrd.c PJ_lsat.c PJ_misrsom.c PJ_merc.c \
PJ_mill.c PJ_ocea.c PJ_omerc.c PJ_somerc.c \
PJ_tcc.c PJ_tcea.c PJ_times.c PJ_tmerc.c \
PJ_airy.c PJ_aitoff.c PJ_august.c PJ_bacon.c \
PJ_chamb.c PJ_hammer.c PJ_lagrng.c PJ_larr.c \
PJ_lask.c PJ_nocol.c PJ_ob_tran.c PJ_oea.c \
PJ_tpeqd.c PJ_vandg.c PJ_vandg2.c PJ_vandg4.c \
PJ_wag7.c PJ_lcca.c PJ_geos.c proj_etmerc.c \
PJ_boggs.c PJ_collg.c PJ_comill.c PJ_crast.c PJ_denoy.c \
PJ_eck1.c PJ_eck2.c PJ_eck3.c PJ_eck4.c \
PJ_eck5.c PJ_fahey.c PJ_fouc_s.c PJ_gins8.c PJ_gstmerc.c \
PJ_gn_sinu.c PJ_goode.c PJ_igh.c PJ_hatano.c PJ_loxim.c \
PJ_mbt_fps.c PJ_mbtfpp.c PJ_mbtfpq.c PJ_moll.c \
PJ_nell.c PJ_nell_h.c PJ_patterson.c PJ_putp2.c PJ_putp3.c \
PJ_putp4p.c PJ_putp5.c PJ_putp6.c PJ_qsc.c PJ_robin.c \
PJ_sch.c PJ_sts.c PJ_urm5.c PJ_urmfps.c PJ_wag2.c \
PJ_wag3.c PJ_wink1.c PJ_wink2.c pj_latlong.c pj_geocent.c \
aasincos.c adjlon.c bch2bps.c bchgen.c \
biveval.c dmstor.c mk_cheby.c pj_auth.c \
pj_deriv.c pj_ell_set.c pj_ellps.c pj_errno.c \
pj_factors.c pj_fwd.c pj_init.c pj_inv.c pj_fwd3d.c pj_inv3d.c\
pj_list.c pj_malloc.c pj_mlfn.c pj_msfn.c proj_mdist.c \
pj_open_lib.c pj_param.c pj_phi2.c pj_pr_list.c \
pj_qsfn.c pj_generic_selftest.c pj_run_selftests.c pj_strerrno.c \
pj_tsfn.c pj_units.c pj_ctx.c pj_log.c pj_zpoly1.c rtodms.c \
vector1.c pj_release.c pj_gauss.c \
PJ_healpix.c PJ_natearth.c PJ_natearth2.c PJ_calcofi.c pj_fileapi.c \
\
pj_gc_reader.c pj_gridcatalog.c \
nad_cvt.c nad_init.c nad_intr.c emess.c emess.h \
pj_apply_gridshift.c pj_datums.c pj_datum_set.c pj_transform.c \
geocent.c geocent.h pj_utils.c pj_gridinfo.c pj_gridlist.c \
jniproj.c pj_mutex.c pj_initcache.c pj_apply_vgridshift.c geodesic.c \
pj_strtod.c
install-exec-local:
rm -f $(DESTDIR)$(bindir)/invproj$(EXEEXT)
(cd $(DESTDIR)$(bindir); ln -s proj$(EXEEXT) invproj$(EXEEXT))
rm -f $(DESTDIR)$(bindir)/invgeod$(EXEEXT)
(cd $(DESTDIR)$(bindir); ln -s geod$(EXEEXT) invgeod$(EXEEXT))
proj-4.9.3/src/test228.c 0000644 0000000 0000000 00000003245 12761101536 011544 0000000 0000000 #include
#include /* for printf declaration */
#ifdef _WIN32
int main(int argc, char* argv[])
{
printf("Test not yet ported on Win32\n");
return 0;
}
#else
#include
#include
#include
#include
volatile int run = 0;
volatile int started = 0;
void* thread_main(void* unused)
{
projCtx p_proj_ctxt;
projPJ p_WGS84_proj;
projPJ p_OSGB36_proj;
__sync_add_and_fetch(&started, 1);
while(run == 0);
p_proj_ctxt=pj_ctx_alloc();
p_WGS84_proj=pj_init_plus_ctx(p_proj_ctxt,"+proj=longlat "
"+ellps=WGS84 +datum=WGS84 +no_defs");
p_OSGB36_proj=pj_init_plus_ctx(p_proj_ctxt,
"+proj=longlat +ellps=airy +datum=OSGB36 +nadgrids=OSTN02_NTv2.gsb "
"+no_defs");
while(run)
{
double x, y;
int proj_ret;
x = -5.2*DEG_TO_RAD;
y = 50*DEG_TO_RAD;
proj_ret = pj_transform(p_WGS84_proj,
p_OSGB36_proj, 1, 1, &x, &y, NULL );
x *= RAD_TO_DEG;
y *= RAD_TO_DEG;
/*printf("%.18f %.18f\n", x, y); */
assert(proj_ret == 0);
assert(fabs(x - -5.198965360936369962) < 1e-15);
assert(fabs(y - 49.999396034285531698) < 1e-15);
}
return NULL;
}
int main(int argc, char* argv[])
{
int i;
pthread_t tid1, tid2;
pthread_attr_t attr1, attr2;
pthread_attr_init(&attr1);
pthread_attr_init(&attr2);
pthread_create(&tid1, &attr1, thread_main, NULL);
pthread_create(&tid2, &attr2, thread_main, NULL);
while(started != 2);
run = 1;
for(i=0;i<2;i++)
sleep(1);
run = 0;
return 0;
}
#endif /* _WIN32 */
proj-4.9.3/src/PJ_lcc.c 0000644 0000000 0000000 00000012171 12761101536 011461 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(lcc, "Lambert Conformal Conic")
"\n\tConic, Sph&Ell\n\tlat_1= and lat_2= or lat_0";
# define EPS10 1.e-10
struct pj_opaque {
double phi1;
double phi2;
double n;
double rho0;
double c;
int ellips;
};
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double rho;
if (fabs(fabs(lp.phi) - M_HALFPI) < EPS10) {
if ((lp.phi * Q->n) <= 0.) F_ERROR;
rho = 0.;
} else {
rho = Q->c * (Q->ellips ? pow(pj_tsfn(lp.phi, sin(lp.phi),
P->e), Q->n) : pow(tan(M_FORTPI + .5 * lp.phi), -Q->n));
}
lp.lam *= Q->n;
xy.x = P->k0 * (rho * sin( lp.lam) );
xy.y = P->k0 * (Q->rho0 - rho * cos(lp.lam) );
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double rho;
xy.x /= P->k0;
xy.y /= P->k0;
xy.y = Q->rho0 - xy.y;
rho = hypot(xy.x, xy.y);
if (rho != 0.0) {
if (Q->n < 0.) {
rho = -rho;
xy.x = -xy.x;
xy.y = -xy.y;
}
if (Q->ellips) {
lp.phi = pj_phi2(P->ctx, pow(rho / Q->c, 1./Q->n), P->e);
if (lp.phi == HUGE_VAL)
I_ERROR;
} else
lp.phi = 2. * atan(pow(Q->c / rho, 1./Q->n)) - M_HALFPI;
lp.lam = atan2(xy.x, xy.y) / Q->n;
} else {
lp.lam = 0.;
lp.phi = Q->n > 0. ? M_HALFPI : -M_HALFPI;
}
return lp;
}
static void special(LP lp, PJ *P, struct FACTORS *fac) {
struct pj_opaque *Q = P->opaque;
double rho;
if (fabs(fabs(lp.phi) - M_HALFPI) < EPS10) {
if ((lp.phi * Q->n) <= 0.) return;
rho = 0.;
} else
rho = Q->c * (Q->ellips ? pow(pj_tsfn(lp.phi, sin(lp.phi),
P->e), Q->n) : pow(tan(M_FORTPI + .5 * lp.phi), -Q->n));
fac->code |= IS_ANAL_HK + IS_ANAL_CONV;
fac->k = fac->h = P->k0 * Q->n * rho /
pj_msfn(sin(lp.phi), cos(lp.phi), P->es);
fac->conv = - Q->n * lp.lam;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(lcc) {
double cosphi, sinphi;
int secant;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
if (pj_param(P->ctx, P->params, "tlat_2").i)
Q->phi2 = pj_param(P->ctx, P->params, "rlat_2").f;
else {
Q->phi2 = Q->phi1;
if (!pj_param(P->ctx, P->params, "tlat_0").i)
P->phi0 = Q->phi1;
}
if (fabs(Q->phi1 + Q->phi2) < EPS10) E_ERROR(-21);
Q->n = sinphi = sin(Q->phi1);
cosphi = cos(Q->phi1);
secant = fabs(Q->phi1 - Q->phi2) >= EPS10;
if( (Q->ellips = (P->es != 0.)) ) {
double ml1, m1;
P->e = sqrt(P->es);
m1 = pj_msfn(sinphi, cosphi, P->es);
ml1 = pj_tsfn(Q->phi1, sinphi, P->e);
if (secant) { /* secant cone */
sinphi = sin(Q->phi2);
Q->n = log(m1 / pj_msfn(sinphi, cos(Q->phi2), P->es));
Q->n /= log(ml1 / pj_tsfn(Q->phi2, sinphi, P->e));
}
Q->c = (Q->rho0 = m1 * pow(ml1, -Q->n) / Q->n);
Q->rho0 *= (fabs(fabs(P->phi0) - M_HALFPI) < EPS10) ? 0. :
pow(pj_tsfn(P->phi0, sin(P->phi0), P->e), Q->n);
} else {
if (secant)
Q->n = log(cosphi / cos(Q->phi2)) /
log(tan(M_FORTPI + .5 * Q->phi2) /
tan(M_FORTPI + .5 * Q->phi1));
Q->c = cosphi * pow(tan(M_FORTPI + .5 * Q->phi1), Q->n) / Q->n;
Q->rho0 = (fabs(fabs(P->phi0) - M_HALFPI) < EPS10) ? 0. :
Q->c * pow(tan(M_FORTPI + .5 * P->phi0), -Q->n);
}
P->inv = e_inverse;
P->fwd = e_forward;
P->spc = special;
return P;
}
#ifndef PJ_SELFTEST
int pj_lcc_selftest (void) {return 0;}
#else
int pj_lcc_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=lcc +ellps=GRS80 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222588.439735968423, 110660.533870799671},
{ 222756.879700278747, -110532.797660827026},
{-222588.439735968423, 110660.533870799671},
{-222756.879700278747, -110532.797660827026},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.00179635940600536667, 0.000904232207322381741},
{ 0.00179635817735249777, -0.000904233135128348995},
{-0.00179635940600536667, 0.000904232207322381741},
{-0.00179635817735249777, -0.000904233135128348995},
};
return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
}
#endif
proj-4.9.3/src/PJ_sch.c 0000644 0000000 0000000 00000020474 12761101536 011502 0000000 0000000 /******************************************************************************
* $Id$
*
* Project: SCH Coordinate system
* Purpose: Implementation of SCH Coordinate system
* References :
* 1. Hensley. Scott. SCH Coordinates and various transformations. June 15, 2000.
* 2. Buckley, Sean Monroe. Radar interferometry measurement of land subsidence. 2000..
* PhD Thesis. UT Austin. (Appendix)
* 3. Hensley, Scott, Elaine Chapin, and T. Michel. "Improved processing of AIRSAR
* data based on the GeoSAR processor." Airsar earth science and applications
* workshop, March. 2002. (http://airsar.jpl.nasa.gov/documents/workshop2002/papers/T3.pdf)
*
* Author: Piyush Agram (piyush.agram@jpl.nasa.gov)
* Copyright (c) 2015 California Institute of Technology.
* Government sponsorship acknowledged.
*
* NOTE: The SCH coordinate system is a sensor aligned coordinate system
* developed at JPL for radar mapping missions. Details pertaining to the
* coordinate system have been release in the public domain (see references above).
* This code is an independent implementation of the SCH coordinate system
* that conforms to the PROJ.4 conventions and uses the details presented in these
* publicly released documents. All credit for the development of the coordinate
* system and its use should be directed towards the original developers at JPL.
******************************************************************************
* 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.
****************************************************************************/
#define PJ_LIB__
#include
#include "geocent.h"
struct pj_opaque {
double plat; /*Peg Latitude */
double plon; /*Peg Longitude*/
double phdg; /*Peg heading */
double h0; /*Average altitude */
double transMat[9];
double xyzoff[3];
double rcurv;
GeocentricInfo sph;
GeocentricInfo elp_0;
};
PROJ_HEAD(sch, "Spherical Cross-track Height") "\n\tMisc\n\tplat_0 = ,plon_0 = , phdg_0 = ,[h_0 = ]";
static LPZ inverse3d(XYZ xyz, PJ *P) {
LPZ lpz = {0.0, 0.0, 0.0};
struct pj_opaque *Q = P->opaque;
double temp[3];
double pxyz[3];
/* Local lat,lon using radius */
pxyz[0] = xyz.y * P->a / Q->rcurv;
pxyz[1] = xyz.x * P->a / Q->rcurv;
pxyz[2] = xyz.z;
if( pj_Convert_Geodetic_To_Geocentric( &(Q->sph), pxyz[0], pxyz[1], pxyz[2],
temp, temp+1, temp+2) != 0)
I3_ERROR;
/* Apply rotation */
pxyz[0] = Q->transMat[0] * temp[0] + Q->transMat[1] * temp[1] + Q->transMat[2] * temp[2];
pxyz[1] = Q->transMat[3] * temp[0] + Q->transMat[4] * temp[1] + Q->transMat[5] * temp[2];
pxyz[2] = Q->transMat[6] * temp[0] + Q->transMat[7] * temp[1] + Q->transMat[8] * temp[2];
/* Apply offset */
pxyz[0] += Q->xyzoff[0];
pxyz[1] += Q->xyzoff[1];
pxyz[2] += Q->xyzoff[2];
/* Convert geocentric coordinates to lat lon */
pj_Convert_Geocentric_To_Geodetic( &(Q->elp_0), pxyz[0], pxyz[1], pxyz[2],
temp, temp+1, temp+2);
lpz.lam = temp[1] ;
lpz.phi = temp[0] ;
lpz.z = temp[2];
#if 0
printf("INVERSE: \n");
printf("XYZ: %f %f %f \n", xyz.x, xyz.y, xyz.z);
printf("LPZ: %f %f %f \n", lpz.lam, lpz.phi, lpz.z);
#endif
return lpz;
}
static XYZ forward3d(LPZ lpz, PJ *P) {
XYZ xyz = {0.0, 0.0, 0.0};
struct pj_opaque *Q = P->opaque;
double temp[3];
double pxyz[3];
/* Convert lat lon to geocentric coordinates */
if( pj_Convert_Geodetic_To_Geocentric( &(Q->elp_0), lpz.phi, lpz.lam, lpz.z,
temp, temp+1, temp+2 ) != 0 )
F3_ERROR;
/* Adjust for offset */
temp[0] -= Q->xyzoff[0];
temp[1] -= Q->xyzoff[1];
temp[2] -= Q->xyzoff[2];
/* Apply rotation */
pxyz[0] = Q->transMat[0] * temp[0] + Q->transMat[3] * temp[1] + Q->transMat[6] * temp[2];
pxyz[1] = Q->transMat[1] * temp[0] + Q->transMat[4] * temp[1] + Q->transMat[7] * temp[2];
pxyz[2] = Q->transMat[2] * temp[0] + Q->transMat[5] * temp[1] + Q->transMat[8] * temp[2];
/* Convert to local lat,lon */
pj_Convert_Geocentric_To_Geodetic( &(Q->sph), pxyz[0], pxyz[1], pxyz[2],
temp, temp+1, temp+2);
/* Scale by radius */
xyz.x = temp[1] * Q->rcurv / P->a;
xyz.y = temp[0] * Q->rcurv / P->a;
xyz.z = temp[2];
#if 0
printf("FORWARD: \n");
printf("LPZ: %f %f %f \n", lpz.lam, lpz.phi, lpz.z);
printf("XYZ: %f %f %f \n", xyz.x, xyz.y, xyz.z);
#endif
return xyz;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
static PJ *setup(PJ *P) { /* general initialization */
struct pj_opaque *Q = P->opaque;
double reast, rnorth;
double chdg, shdg;
double clt, slt;
double clo, slo;
double temp;
double pxyz[3];
temp = P->a * sqrt(1.0 - P->es);
/* Setup original geocentric system */
if ( pj_Set_Geocentric_Parameters(&(Q->elp_0), P->a, temp) != 0)
E_ERROR(-37);
clt = cos(Q->plat);
slt = sin(Q->plat);
clo = cos(Q->plon);
slo = sin(Q->plon);
/* Estimate the radius of curvature for given peg */
temp = sqrt(1.0 - (P->es) * slt * slt);
reast = (P->a)/temp;
rnorth = (P->a) * (1.0 - (P->es))/pow(temp,3);
chdg = cos(Q->phdg);
shdg = sin(Q->phdg);
Q->rcurv = Q->h0 + (reast*rnorth)/(reast * chdg * chdg + rnorth * shdg * shdg);
#if 0
printf("North Radius: %f \n", rnorth);
printf("East Radius: %f \n", reast);
printf("Effective Radius: %f \n", Q->rcurv);
#endif
/* Set up local sphere at the given peg point */
if ( pj_Set_Geocentric_Parameters(&(Q->sph), Q->rcurv, Q->rcurv) != 0)
E_ERROR(-37);
/* Set up the transformation matrices */
Q->transMat[0] = clt * clo;
Q->transMat[1] = -shdg*slo - slt*clo * chdg;
Q->transMat[2] = slo*chdg - slt*clo*shdg;
Q->transMat[3] = clt*slo;
Q->transMat[4] = clo*shdg - slt*slo*chdg;
Q->transMat[5] = -clo*chdg - slt*slo*shdg;
Q->transMat[6] = slt;
Q->transMat[7] = clt*chdg;
Q->transMat[8] = clt*shdg;
if( pj_Convert_Geodetic_To_Geocentric( &(Q->elp_0), Q->plat, Q->plon, Q->h0,
pxyz, pxyz+1, pxyz+2 ) != 0 )
{
E_ERROR(-14)
}
Q->xyzoff[0] = pxyz[0] - (Q->rcurv) * clt * clo;
Q->xyzoff[1] = pxyz[1] - (Q->rcurv) * clt * slo;
Q->xyzoff[2] = pxyz[2] - (Q->rcurv) * slt;
#if 0
printf("Offset: %f %f %f \n", Q->xyzoff[0], Q->xyzoff[1], Q->xyzoff[2]);
#endif
P->fwd3d = forward3d;
P->inv3d = inverse3d;
return P;
}
PJ *PROJECTION(sch) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->h0 = 0.0;
/* Check if peg latitude was defined */
if (pj_param(P->ctx, P->params, "tplat_0").i)
Q->plat = pj_param(P->ctx, P->params, "rplat_0").f;
else
E_ERROR(-37);
/* Check if peg longitude was defined */
if (pj_param(P->ctx, P->params, "tplon_0").i)
Q->plon = pj_param(P->ctx, P->params, "rplon_0").f;
else
E_ERROR(-37);
/* Check if peg latitude is defined */
if (pj_param(P->ctx, P->params, "tphdg_0").i)
Q->phdg = pj_param(P->ctx, P->params, "rphdg_0").f;
else
E_ERROR(-37);
/* Check if average height was defined - If so read it in */
if (pj_param(P->ctx, P->params, "th_0").i)
Q->h0 = pj_param(P->ctx, P->params, "dh_0").f;
/* Completed reading in the projection parameters */
#if 0
printf("PSA: Lat = %f Lon = %f Hdg = %f \n", Q->plat, Q->plon, Q->phdg);
#endif
return setup(P);
}
/* Skipping sef-test since the test system is not capable of handling
* 3D coordinate systems for the time being. Relying on tests in ../nad/
*/
int pj_sch_selftest (void) {return 0;}
proj-4.9.3/src/PJ_goode.c 0000644 0000000 0000000 00000005531 12761101536 012017 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(goode, "Goode Homolosine") "\n\tPCyl, Sph.";
#define Y_COR 0.05280
#define PHI_LIM 0.71093078197902358062
C_NAMESPACE PJ *pj_sinu(PJ *), *pj_moll(PJ *);
struct pj_opaque {
PJ *sinu;
PJ *moll;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
if (fabs(lp.phi) <= PHI_LIM)
xy = Q->sinu->fwd(lp, Q->sinu);
else {
xy = Q->moll->fwd(lp, Q->moll);
xy.y -= lp.phi >= 0.0 ? Y_COR : -Y_COR;
}
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
if (fabs(xy.y) <= PHI_LIM)
lp = Q->sinu->inv(xy, Q->sinu);
else {
xy.y += xy.y >= 0.0 ? Y_COR : -Y_COR;
lp = Q->moll->inv(xy, Q->moll);
}
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc(P);
if (P->opaque->sinu)
pj_dealloc(P->opaque->sinu);
if (P->opaque->moll)
pj_dealloc(P->opaque->moll);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(goode) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
P->es = 0.;
if (!(Q->sinu = pj_sinu(0)) || !(Q->moll = pj_moll(0)))
E_ERROR_0;
Q->sinu->es = 0.;
Q->sinu->ctx = P->ctx;
Q->moll->ctx = P->ctx;
if (!(Q->sinu = pj_sinu(Q->sinu)) || !(Q->moll = pj_moll(Q->moll)))
E_ERROR_0;
P->fwd = s_forward;
P->inv = s_inverse;
return P;
}
#ifndef PJ_SELFTEST
int pj_goode_selftest (void) {return 0;}
#else
int pj_goode_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=goode +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223368.11902663155, 111701.07212763709},
{ 223368.11902663155, -111701.07212763709},
{-223368.11902663155, 111701.07212763709},
{-223368.11902663155, -111701.07212763709},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0017904931100023887, 0.00089524655489191132},
{ 0.0017904931100023887, -0.00089524655489191132},
{-0.0017904931100023887, 0.00089524655489191132},
{-0.0017904931100023887, -0.00089524655489191132},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/pj_log.c 0000644 0000000 0000000 00000005074 12761101536 011605 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Implementation of pj_log() function.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2010, 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.
*****************************************************************************/
#include
#include
#include
/************************************************************************/
/* pj_stderr_logger() */
/************************************************************************/
void pj_stderr_logger( void *app_data, int level, const char *msg )
{
(void) app_data;
(void) level;
fprintf( stderr, "%s\n", msg );
}
/************************************************************************/
/* pj_log() */
/************************************************************************/
void pj_log( projCtx ctx, int level, const char *fmt, ... )
{
va_list args;
char *msg_buf;
if( level > ctx->debug_level )
return;
msg_buf = (char *) malloc(100000);
if( msg_buf == NULL )
return;
va_start( args, fmt );
/* we should use vsnprintf where available once we add configure detect.*/
vsprintf( msg_buf, fmt, args );
va_end( args );
ctx->logger( ctx->app_data, level, msg_buf );
free( msg_buf );
}
proj-4.9.3/src/geocent.h 0000644 0000000 0000000 00000014213 12761101536 011757 0000000 0000000 #ifndef GEOCENT_H
#define GEOCENT_H
/***************************************************************************/
/* RSC IDENTIFIER: GEOCENTRIC
*
* ABSTRACT
*
* This component provides conversions between Geodetic coordinates (latitude,
* longitude in radians and height in meters) and Geocentric coordinates
* (X, Y, Z) in meters.
*
* ERROR HANDLING
*
* This component checks parameters for valid values. If an invalid value
* is found, the error code is combined with the current error code using
* the bitwise or. This combining allows multiple error codes to be
* returned. The possible error codes are:
*
* GEOCENT_NO_ERROR : No errors occurred in function
* GEOCENT_LAT_ERROR : Latitude out of valid range
* (-90 to 90 degrees)
* GEOCENT_LON_ERROR : Longitude out of valid range
* (-180 to 360 degrees)
* GEOCENT_A_ERROR : Semi-major axis less than or equal to zero
* GEOCENT_B_ERROR : Semi-minor axis less than or equal to zero
* GEOCENT_A_LESS_B_ERROR : Semi-major axis less than semi-minor axis
*
*
* REUSE NOTES
*
* GEOCENTRIC is intended for reuse by any application that performs
* coordinate conversions between geodetic coordinates and geocentric
* coordinates.
*
*
* REFERENCES
*
* An Improved Algorithm for Geocentric to Geodetic Coordinate Conversion,
* Ralph Toms, February 1996 UCRL-JC-123138.
*
* Further information on GEOCENTRIC can be found in the Reuse Manual.
*
* GEOCENTRIC originated from : U.S. Army Topographic Engineering Center
* Geospatial Information Division
* 7701 Telegraph Road
* Alexandria, VA 22310-3864
*
* LICENSES
*
* None apply to this component.
*
* RESTRICTIONS
*
* GEOCENTRIC has no restrictions.
*
* ENVIRONMENT
*
* GEOCENTRIC was tested and certified in the following environments:
*
* 1. Solaris 2.5 with GCC version 2.8.1
* 2. Windows 95 with MS Visual C++ version 6
*
* MODIFICATIONS
*
* Date Description
* ---- -----------
*
*
*/
/***************************************************************************/
/*
* DEFINES
*/
#define GEOCENT_NO_ERROR 0x0000
#define GEOCENT_LAT_ERROR 0x0001
#define GEOCENT_LON_ERROR 0x0002
#define GEOCENT_A_ERROR 0x0004
#define GEOCENT_B_ERROR 0x0008
#define GEOCENT_A_LESS_B_ERROR 0x0010
/***************************************************************************/
/*
* FUNCTION PROTOTYPES
*/
/* ensure proper linkage to c++ programs */
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
double Geocent_a; /* Semi-major axis of ellipsoid in meters */
double Geocent_b; /* Semi-minor axis of ellipsoid */
double Geocent_a2; /* Square of semi-major axis */
double Geocent_b2; /* Square of semi-minor axis */
double Geocent_e2; /* Eccentricity squared */
double Geocent_ep2; /* 2nd eccentricity squared */
} GeocentricInfo;
void pj_Init_Geocentric( GeocentricInfo *gi );
long pj_Set_Geocentric_Parameters( GeocentricInfo *gi,
double a,
double b);
/*
* The function Set_Geocentric_Parameters receives the ellipsoid parameters
* as inputs and sets the corresponding state variables.
*
* a : Semi-major axis, in meters. (input)
* b : Semi-minor axis, in meters. (input)
*/
void pj_Get_Geocentric_Parameters ( GeocentricInfo *gi,
double *a,
double *b);
/*
* The function Get_Geocentric_Parameters returns the ellipsoid parameters
* to be used in geocentric coordinate conversions.
*
* a : Semi-major axis, in meters. (output)
* b : Semi-minor axis, in meters. (output)
*/
long pj_Convert_Geodetic_To_Geocentric ( GeocentricInfo *gi,
double Latitude,
double Longitude,
double Height,
double *X,
double *Y,
double *Z);
/*
* The function Convert_Geodetic_To_Geocentric converts geodetic coordinates
* (latitude, longitude, and height) to geocentric coordinates (X, Y, Z),
* according to the current ellipsoid parameters.
*
* Latitude : Geodetic latitude in radians (input)
* Longitude : Geodetic longitude in radians (input)
* Height : Geodetic height, in meters (input)
* X : Calculated Geocentric X coordinate, in meters. (output)
* Y : Calculated Geocentric Y coordinate, in meters. (output)
* Z : Calculated Geocentric Z coordinate, in meters. (output)
*
*/
void pj_Convert_Geocentric_To_Geodetic (GeocentricInfo *gi,
double X,
double Y,
double Z,
double *Latitude,
double *Longitude,
double *Height);
/*
* The function Convert_Geocentric_To_Geodetic converts geocentric
* coordinates (X, Y, Z) to geodetic coordinates (latitude, longitude,
* and height), according to the current ellipsoid parameters.
*
* X : Geocentric X coordinate, in meters. (input)
* Y : Geocentric Y coordinate, in meters. (input)
* Z : Geocentric Z coordinate, in meters. (input)
* Latitude : Calculated latitude value in radians. (output)
* Longitude : Calculated longitude value in radians. (output)
* Height : Calculated height value, in meters. (output)
*/
#ifdef __cplusplus
}
#endif
#endif /* GEOCENT_H */
proj-4.9.3/src/PJ_aea.c 0000644 0000000 0000000 00000022066 12761101536 011452 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Implementation of the aea (Albers Equal Area) projection.
* and the leac (Lambert Equal Area Conic) projection
* Author: Gerald Evenden (1995)
* Thomas Knudsen (2016) - revise/add regression tests
*
******************************************************************************
* Copyright (c) 1995, Gerald Evenden
*
* 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.
*****************************************************************************/
#define PJ_LIB__
#include
# define EPS10 1.e-10
# define TOL7 1.e-7
PROJ_HEAD(aea, "Albers Equal Area") "\n\tConic Sph&Ell\n\tlat_1= lat_2=";
PROJ_HEAD(leac, "Lambert Equal Area Conic") "\n\tConic, Sph&Ell\n\tlat_1= south";
/* determine latitude angle phi-1 */
# define N_ITER 15
# define EPSILON 1.0e-7
# define TOL 1.0e-10
static double phi1_(double qs, double Te, double Tone_es) {
int i;
double Phi, sinpi, cospi, con, com, dphi;
Phi = asin (.5 * qs);
if (Te < EPSILON)
return( Phi );
i = N_ITER;
do {
sinpi = sin (Phi);
cospi = cos (Phi);
con = Te * sinpi;
com = 1. - con * con;
dphi = .5 * com * com / cospi * (qs / Tone_es -
sinpi / com + .5 / Te * log ((1. - con) /
(1. + con)));
Phi += dphi;
} while (fabs(dphi) > TOL && --i);
return( i ? Phi : HUGE_VAL );
}
struct pj_opaque {
double ec;
double n;
double c;
double dd;
double n2;
double rho0;
double rho;
double phi1;
double phi2;
double *en;
int ellips;
};
static XY e_forward (LP lp, PJ *P) { /* Ellipsoid/spheroid, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
if ((Q->rho = Q->c - (Q->ellips ? Q->n * pj_qsfn(sin(lp.phi),
P->e, P->one_es) : Q->n2 * sin(lp.phi))) < 0.) F_ERROR
Q->rho = Q->dd * sqrt(Q->rho);
xy.x = Q->rho * sin( lp.lam *= Q->n );
xy.y = Q->rho0 - Q->rho * cos(lp.lam);
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoid/spheroid, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
if( (Q->rho = hypot(xy.x, xy.y = Q->rho0 - xy.y)) != 0.0 ) {
if (Q->n < 0.) {
Q->rho = -Q->rho;
xy.x = -xy.x;
xy.y = -xy.y;
}
lp.phi = Q->rho / Q->dd;
if (Q->ellips) {
lp.phi = (Q->c - lp.phi * lp.phi) / Q->n;
if (fabs(Q->ec - fabs(lp.phi)) > TOL7) {
if ((lp.phi = phi1_(lp.phi, P->e, P->one_es)) == HUGE_VAL)
I_ERROR
} else
lp.phi = lp.phi < 0. ? -M_HALFPI : M_HALFPI;
} else if (fabs(lp.phi = (Q->c - lp.phi * lp.phi) / Q->n2) <= 1.)
lp.phi = asin(lp.phi);
else
lp.phi = lp.phi < 0. ? -M_HALFPI : M_HALFPI;
lp.lam = atan2(xy.x, xy.y) / Q->n;
} else {
lp.lam = 0.;
lp.phi = Q->n > 0. ? M_HALFPI : - M_HALFPI;
}
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque->en);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
static PJ *setup(PJ *P) {
double cosphi, sinphi;
int secant;
struct pj_opaque *Q = P->opaque;
P->inv = e_inverse;
P->fwd = e_forward;
if (fabs(Q->phi1 + Q->phi2) < EPS10) E_ERROR(-21);
Q->n = sinphi = sin(Q->phi1);
cosphi = cos(Q->phi1);
secant = fabs(Q->phi1 - Q->phi2) >= EPS10;
if( (Q->ellips = (P->es > 0.))) {
double ml1, m1;
if (!(Q->en = pj_enfn(P->es))) E_ERROR_0;
m1 = pj_msfn(sinphi, cosphi, P->es);
ml1 = pj_qsfn(sinphi, P->e, P->one_es);
if (secant) { /* secant cone */
double ml2, m2;
sinphi = sin(Q->phi2);
cosphi = cos(Q->phi2);
m2 = pj_msfn(sinphi, cosphi, P->es);
ml2 = pj_qsfn(sinphi, P->e, P->one_es);
Q->n = (m1 * m1 - m2 * m2) / (ml2 - ml1);
}
Q->ec = 1. - .5 * P->one_es * log((1. - P->e) /
(1. + P->e)) / P->e;
Q->c = m1 * m1 + Q->n * ml1;
Q->dd = 1. / Q->n;
Q->rho0 = Q->dd * sqrt(Q->c - Q->n * pj_qsfn(sin(P->phi0),
P->e, P->one_es));
} else {
if (secant) Q->n = .5 * (Q->n + sin(Q->phi2));
Q->n2 = Q->n + Q->n;
Q->c = cosphi * cosphi + Q->n2 * sinphi;
Q->dd = 1. / Q->n;
Q->rho0 = Q->dd * sqrt(Q->c - Q->n2 * sin(P->phi0));
}
return P;
}
PJ *PROJECTION(aea) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
Q->phi2 = pj_param(P->ctx, P->params, "rlat_2").f;
setup(P);
return P;
}
PJ *PROJECTION(leac) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->phi2 = pj_param(P->ctx, P->params, "rlat_1").f;
Q->phi1 = pj_param(P->ctx, P->params, "bsouth").i ? - M_HALFPI: M_HALFPI;
setup (P);
return P;
}
#ifndef PJ_SELFTEST
int pj_aea_selftest (void) {return 10000;}
#else
int pj_aea_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=aea +ellps=GRS80 +lat_1=0 +lat_2=2"};
char s_args[] = {"+proj=aea +a=6400000 +lat_1=0 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{222571.60875710563, 110653.32674302977},
{222706.30650839131, -110484.26714439997},
{-222571.60875710563, 110653.32674302977},
{-222706.30650839131, -110484.26714439997},
};
XY s_fwd_expect[] = {
{223334.08517088494, 111780.43188447191},
{223470.15499168713, -111610.33943099028},
{-223334.08517088494, 111780.43188447191},
{-223470.15499168713, -111610.33943099028},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{0.0017966310597749514, 0.00090436885862202158},
{0.0017966300767030448, -0.00090437009538581453},
{-0.0017966310597749514, 0.00090436885862202158},
{-0.0017966300767030448, -0.00090437009538581453},
};
LP s_inv_expect[] = {
{0.0017904935979658752, 0.00089524594491375306},
{0.0017904926216016812, -0.00089524716502493225},
{-0.0017904935979658752, 0.00089524594491375306},
{-0.0017904926216016812, -0.00089524716502493225},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_leac_selftest (void) {return 10000;}
#else
int pj_leac_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=leac +ellps=GRS80 +lat_1=0 +lat_2=2"};
char s_args[] = {"+proj=leac +a=6400000 +lat_1=0 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{220685.14054297868, 112983.50088939646},
{224553.31227982609, -108128.63674487274},
{-220685.14054297868, 112983.50088939646},
{-224553.31227982609, -108128.63674487274},
};
XY s_fwd_expect[] = {
{221432.86859285168, 114119.45452653214},
{225331.72412711097, -109245.82943505641},
{-221432.86859285168, 114119.45452653214},
{-225331.72412711097, -109245.82943505641},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{0.0017966446840328458, 0.00090435171340223211},
{0.0017966164523713021, -0.00090438724081843625},
{-0.0017966446840328458, 0.00090435171340223211},
{-0.0017966164523713021, -0.00090438724081843625},
};
LP s_inv_expect[] = {
{0.0017905070979748127, 0.00089522906964877795},
{0.001790479121519977, -0.00089526404022281043},
{-0.0017905070979748127, 0.00089522906964877795},
{-0.001790479121519977, -0.00089526404022281043},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_vandg.c 0000644 0000000 0000000 00000010017 12761101536 012014 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(vandg, "van der Grinten (I)") "\n\tMisc Sph";
# define TOL 1.e-10
# define THIRD .33333333333333333333
# define TWO_THRD .66666666666666666666
# define C2_27 .07407407407407407407
# define PI4_3 4.18879020478639098458
# define PISQ 9.86960440108935861869
# define TPISQ 19.73920880217871723738
# define HPISQ 4.93480220054467930934
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
double al, al2, g, g2, p2;
p2 = fabs(lp.phi / M_HALFPI);
if ((p2 - TOL) > 1.) F_ERROR;
if (p2 > 1.)
p2 = 1.;
if (fabs(lp.phi) <= TOL) {
xy.x = lp.lam;
xy.y = 0.;
} else if (fabs(lp.lam) <= TOL || fabs(p2 - 1.) < TOL) {
xy.x = 0.;
xy.y = M_PI * tan(.5 * asin(p2));
if (lp.phi < 0.) xy.y = -xy.y;
} else {
al = .5 * fabs(M_PI / lp.lam - lp.lam / M_PI);
al2 = al * al;
g = sqrt(1. - p2 * p2);
g = g / (p2 + g - 1.);
g2 = g * g;
p2 = g * (2. / p2 - 1.);
p2 = p2 * p2;
xy.x = g - p2; g = p2 + al2;
xy.x = M_PI * (al * xy.x + sqrt(al2 * xy.x * xy.x - g * (g2 - p2))) / g;
if (lp.lam < 0.) xy.x = -xy.x;
xy.y = fabs(xy.x / M_PI);
xy.y = 1. - xy.y * (xy.y + 2. * al);
if (xy.y < -TOL) F_ERROR;
if (xy.y < 0.)
xy.y = 0.;
else
xy.y = sqrt(xy.y) * (lp.phi < 0. ? -M_PI : M_PI);
}
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
double t, c0, c1, c2, c3, al, r2, r, m, d, ay, x2, y2;
x2 = xy.x * xy.x;
if ((ay = fabs(xy.y)) < TOL) {
lp.phi = 0.;
t = x2 * x2 + TPISQ * (x2 + HPISQ);
lp.lam = fabs(xy.x) <= TOL ? 0. :
.5 * (x2 - PISQ + sqrt(t)) / xy.x;
return (lp);
}
y2 = xy.y * xy.y;
r = x2 + y2; r2 = r * r;
c1 = - M_PI * ay * (r + PISQ);
c3 = r2 + M_TWOPI * (ay * r + M_PI * (y2 + M_PI * (ay + M_HALFPI)));
c2 = c1 + PISQ * (r - 3. * y2);
c0 = M_PI * ay;
c2 /= c3;
al = c1 / c3 - THIRD * c2 * c2;
m = 2. * sqrt(-THIRD * al);
d = C2_27 * c2 * c2 * c2 + (c0 * c0 - THIRD * c2 * c1) / c3;
if (((t = fabs(d = 3. * d / (al * m))) - TOL) <= 1.) {
d = t > 1. ? (d > 0. ? 0. : M_PI) : acos(d);
lp.phi = M_PI * (m * cos(d * THIRD + PI4_3) - THIRD * c2);
if (xy.y < 0.) lp.phi = -lp.phi;
t = r2 + TPISQ * (x2 - y2 + HPISQ);
lp.lam = fabs(xy.x) <= TOL ? 0. :
.5 * (r - PISQ + (t <= 0. ? 0. : sqrt(t))) / xy.x;
} else
I_ERROR;
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(vandg) {
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_vandg_selftest (void) {return 0;}
#else
int pj_vandg_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=vandg +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223395.24954340671, 111704.59663367498},
{ 223395.24954340671, -111704.59663367498},
{-223395.24954340671, 111704.59663367498},
{-223395.24954340671, -111704.59663367498},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.001790493715929761, 0.00089524655486993867},
{ 0.001790493715929761, -0.00089524655486993867},
{-0.001790493715929761, 0.00089524655486993867},
{-0.001790493715929761, -0.00089524655486993867},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/pj_transform.c 0000644 0000000 0000000 00000101727 12761101536 013041 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Perform overall coordinate system to coordinate system
* transformations (pj_transform() function) including reprojection
* and datum shifting.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* 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.
*****************************************************************************/
#include
#include
#include
#include "geocent.h"
static int pj_adjust_axis( projCtx ctx, const char *axis, int denormalize_flag,
long point_count, int point_offset,
double *x, double *y, double *z );
#ifndef SRS_WGS84_SEMIMAJOR
#define SRS_WGS84_SEMIMAJOR 6378137.0
#endif
#ifndef SRS_WGS84_ESQUARED
#define SRS_WGS84_ESQUARED 0.0066943799901413165
#endif
#define Dx_BF (defn->datum_params[0])
#define Dy_BF (defn->datum_params[1])
#define Dz_BF (defn->datum_params[2])
#define Rx_BF (defn->datum_params[3])
#define Ry_BF (defn->datum_params[4])
#define Rz_BF (defn->datum_params[5])
#define M_BF (defn->datum_params[6])
/*
** This table is intended to indicate for any given error code in
** the range 0 to -44, whether that error will occur for all locations (ie.
** it is a problem with the coordinate system as a whole) in which case the
** value would be 0, or if the problem is with the point being transformed
** in which case the value is 1.
**
** At some point we might want to move this array in with the error message
** list or something, but while experimenting with it this should be fine.
*/
static const int transient_error[50] = {
/* 0 1 2 3 4 5 6 7 8 9 */
/* 0 to 9 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 10 to 19 */ 0, 0, 0, 0, 1, 1, 0, 1, 1, 1,
/* 20 to 29 */ 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
/* 30 to 39 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 40 to 49 */ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 };
/************************************************************************/
/* pj_transform() */
/* */
/* Currently this function doesn't recognise if two projections */
/* are identical (to short circuit reprojection) because it is */
/* difficult to compare PJ structures (since there are some */
/* projection specific components). */
/************************************************************************/
int pj_transform( PJ *srcdefn, PJ *dstdefn, long point_count, int point_offset,
double *x, double *y, double *z )
{
long i;
int err;
srcdefn->ctx->last_errno = 0;
dstdefn->ctx->last_errno = 0;
if( point_offset == 0 )
point_offset = 1;
/* -------------------------------------------------------------------- */
/* Transform unusual input coordinate axis orientation to */
/* standard form if needed. */
/* -------------------------------------------------------------------- */
if( strcmp(srcdefn->axis,"enu") != 0 )
{
int err;
err = pj_adjust_axis( srcdefn->ctx, srcdefn->axis,
0, point_count, point_offset, x, y, z );
if( err != 0 )
return err;
}
/* -------------------------------------------------------------------- */
/* Transform Z to meters if it isn't already. */
/* -------------------------------------------------------------------- */
if( srcdefn->vto_meter != 1.0 && z != NULL )
{
for( i = 0; i < point_count; i++ )
z[point_offset*i] *= srcdefn->vto_meter;
}
/* -------------------------------------------------------------------- */
/* Transform geocentric source coordinates to lat/long. */
/* -------------------------------------------------------------------- */
if( srcdefn->is_geocent )
{
if( z == NULL )
{
pj_ctx_set_errno( pj_get_ctx(srcdefn), PJD_ERR_GEOCENTRIC);
return PJD_ERR_GEOCENTRIC;
}
if( srcdefn->to_meter != 1.0 )
{
for( i = 0; i < point_count; i++ )
{
if( x[point_offset*i] != HUGE_VAL )
{
x[point_offset*i] *= srcdefn->to_meter;
y[point_offset*i] *= srcdefn->to_meter;
}
}
}
err = pj_geocentric_to_geodetic( srcdefn->a_orig, srcdefn->es_orig,
point_count, point_offset,
x, y, z );
if( err != 0 )
return err;
}
/* -------------------------------------------------------------------- */
/* Transform source points to lat/long, if they aren't */
/* already. */
/* -------------------------------------------------------------------- */
else if( !srcdefn->is_latlong )
{
/* Check first if projection is invertible. */
if( (srcdefn->inv3d == NULL) && (srcdefn->inv == NULL))
{
pj_ctx_set_errno( pj_get_ctx(srcdefn), -17 );
pj_log( pj_get_ctx(srcdefn), PJ_LOG_ERROR,
"pj_transform(): source projection not invertable" );
return -17;
}
/* If invertible - First try inv3d if defined */
if (srcdefn->inv3d != NULL)
{
/* Three dimensions must be defined */
if ( z == NULL)
{
pj_ctx_set_errno( pj_get_ctx(srcdefn), PJD_ERR_GEOCENTRIC);
return PJD_ERR_GEOCENTRIC;
}
for (i=0; i < point_count; i++)
{
XYZ projected_loc;
XYZ geodetic_loc;
projected_loc.u = x[point_offset*i];
projected_loc.v = y[point_offset*i];
projected_loc.w = z[point_offset*i];
if (projected_loc.u == HUGE_VAL)
continue;
geodetic_loc = pj_inv3d(projected_loc, srcdefn);
if( srcdefn->ctx->last_errno != 0 )
{
if( (srcdefn->ctx->last_errno != 33 /*EDOM*/
&& srcdefn->ctx->last_errno != 34 /*ERANGE*/ )
&& (srcdefn->ctx->last_errno > 0
|| srcdefn->ctx->last_errno < -44 || point_count == 1
|| transient_error[-srcdefn->ctx->last_errno] == 0 ) )
return srcdefn->ctx->last_errno;
else
{
geodetic_loc.u = HUGE_VAL;
geodetic_loc.v = HUGE_VAL;
geodetic_loc.w = HUGE_VAL;
}
}
x[point_offset*i] = geodetic_loc.u;
y[point_offset*i] = geodetic_loc.v;
z[point_offset*i] = geodetic_loc.w;
}
}
else
{
/* Fallback to the original PROJ.4 API 2d inversion - inv */
for( i = 0; i < point_count; i++ )
{
XY projected_loc;
LP geodetic_loc;
projected_loc.u = x[point_offset*i];
projected_loc.v = y[point_offset*i];
if( projected_loc.u == HUGE_VAL )
continue;
geodetic_loc = pj_inv( projected_loc, srcdefn );
if( srcdefn->ctx->last_errno != 0 )
{
if( (srcdefn->ctx->last_errno != 33 /*EDOM*/
&& srcdefn->ctx->last_errno != 34 /*ERANGE*/ )
&& (srcdefn->ctx->last_errno > 0
|| srcdefn->ctx->last_errno < -44 || point_count == 1
|| transient_error[-srcdefn->ctx->last_errno] == 0 ) )
return srcdefn->ctx->last_errno;
else
{
geodetic_loc.u = HUGE_VAL;
geodetic_loc.v = HUGE_VAL;
}
}
x[point_offset*i] = geodetic_loc.u;
y[point_offset*i] = geodetic_loc.v;
}
}
}
/* -------------------------------------------------------------------- */
/* But if they are already lat long, adjust for the prime */
/* meridian if there is one in effect. */
/* -------------------------------------------------------------------- */
if( srcdefn->from_greenwich != 0.0 )
{
for( i = 0; i < point_count; i++ )
{
if( x[point_offset*i] != HUGE_VAL )
x[point_offset*i] += srcdefn->from_greenwich;
}
}
/* -------------------------------------------------------------------- */
/* Do we need to translate from geoid to ellipsoidal vertical */
/* datum? */
/* -------------------------------------------------------------------- */
if( srcdefn->has_geoid_vgrids && z != NULL )
{
if( pj_apply_vgridshift( srcdefn, "sgeoidgrids",
&(srcdefn->vgridlist_geoid),
&(srcdefn->vgridlist_geoid_count),
0, point_count, point_offset, x, y, z ) != 0 )
return pj_ctx_get_errno(srcdefn->ctx);
}
/* -------------------------------------------------------------------- */
/* Convert datums if needed, and possible. */
/* -------------------------------------------------------------------- */
if( pj_datum_transform( srcdefn, dstdefn, point_count, point_offset,
x, y, z ) != 0 )
{
if( srcdefn->ctx->last_errno != 0 )
return srcdefn->ctx->last_errno;
else
return dstdefn->ctx->last_errno;
}
/* -------------------------------------------------------------------- */
/* Do we need to translate from geoid to ellipsoidal vertical */
/* datum? */
/* -------------------------------------------------------------------- */
if( dstdefn->has_geoid_vgrids && z != NULL )
{
if( pj_apply_vgridshift( dstdefn, "sgeoidgrids",
&(dstdefn->vgridlist_geoid),
&(dstdefn->vgridlist_geoid_count),
1, point_count, point_offset, x, y, z ) != 0 )
return dstdefn->ctx->last_errno;
}
/* -------------------------------------------------------------------- */
/* But if they are staying lat long, adjust for the prime */
/* meridian if there is one in effect. */
/* -------------------------------------------------------------------- */
if( dstdefn->from_greenwich != 0.0 )
{
for( i = 0; i < point_count; i++ )
{
if( x[point_offset*i] != HUGE_VAL )
x[point_offset*i] -= dstdefn->from_greenwich;
}
}
/* -------------------------------------------------------------------- */
/* Transform destination latlong to geocentric if required. */
/* -------------------------------------------------------------------- */
if( dstdefn->is_geocent )
{
if( z == NULL )
{
pj_ctx_set_errno( dstdefn->ctx, PJD_ERR_GEOCENTRIC );
return PJD_ERR_GEOCENTRIC;
}
pj_geodetic_to_geocentric( dstdefn->a_orig, dstdefn->es_orig,
point_count, point_offset, x, y, z );
if( dstdefn->fr_meter != 1.0 )
{
for( i = 0; i < point_count; i++ )
{
if( x[point_offset*i] != HUGE_VAL )
{
x[point_offset*i] *= dstdefn->fr_meter;
y[point_offset*i] *= dstdefn->fr_meter;
}
}
}
}
/* -------------------------------------------------------------------- */
/* Transform destination points to projection coordinates, if */
/* desired. */
/* -------------------------------------------------------------------- */
else if( !dstdefn->is_latlong )
{
if( dstdefn->fwd3d != NULL)
{
for( i = 0; i < point_count; i++ )
{
XYZ projected_loc;
LPZ geodetic_loc;
geodetic_loc.u = x[point_offset*i];
geodetic_loc.v = y[point_offset*i];
geodetic_loc.w = z[point_offset*i];
if (geodetic_loc.u == HUGE_VAL)
continue;
projected_loc = pj_fwd3d( geodetic_loc, dstdefn);
if( dstdefn->ctx->last_errno != 0 )
{
if( (dstdefn->ctx->last_errno != 33 /*EDOM*/
&& dstdefn->ctx->last_errno != 34 /*ERANGE*/ )
&& (dstdefn->ctx->last_errno > 0
|| dstdefn->ctx->last_errno < -44 || point_count == 1
|| transient_error[-dstdefn->ctx->last_errno] == 0 ) )
return dstdefn->ctx->last_errno;
else
{
projected_loc.u = HUGE_VAL;
projected_loc.v = HUGE_VAL;
projected_loc.w = HUGE_VAL;
}
}
x[point_offset*i] = projected_loc.u;
y[point_offset*i] = projected_loc.v;
z[point_offset*i] = projected_loc.w;
}
}
else
{
for( i = 0; i < point_count; i++ )
{
XY projected_loc;
LP geodetic_loc;
geodetic_loc.u = x[point_offset*i];
geodetic_loc.v = y[point_offset*i];
if( geodetic_loc.u == HUGE_VAL )
continue;
projected_loc = pj_fwd( geodetic_loc, dstdefn );
if( dstdefn->ctx->last_errno != 0 )
{
if( (dstdefn->ctx->last_errno != 33 /*EDOM*/
&& dstdefn->ctx->last_errno != 34 /*ERANGE*/ )
&& (dstdefn->ctx->last_errno > 0
|| dstdefn->ctx->last_errno < -44 || point_count == 1
|| transient_error[-dstdefn->ctx->last_errno] == 0 ) )
return dstdefn->ctx->last_errno;
else
{
projected_loc.u = HUGE_VAL;
projected_loc.v = HUGE_VAL;
}
}
x[point_offset*i] = projected_loc.u;
y[point_offset*i] = projected_loc.v;
}
}
}
/* -------------------------------------------------------------------- */
/* If a wrapping center other than 0 is provided, rewrap around */
/* the suggested center (for latlong coordinate systems only). */
/* -------------------------------------------------------------------- */
else if( dstdefn->is_latlong && dstdefn->is_long_wrap_set )
{
for( i = 0; i < point_count; i++ )
{
if( x[point_offset*i] == HUGE_VAL )
continue;
while( x[point_offset*i] < dstdefn->long_wrap_center - M_PI )
x[point_offset*i] += M_TWOPI;
while( x[point_offset*i] > dstdefn->long_wrap_center + M_PI )
x[point_offset*i] -= M_TWOPI;
}
}
/* -------------------------------------------------------------------- */
/* Transform Z from meters if needed. */
/* -------------------------------------------------------------------- */
if( dstdefn->vto_meter != 1.0 && z != NULL )
{
for( i = 0; i < point_count; i++ )
z[point_offset*i] *= dstdefn->vfr_meter;
}
/* -------------------------------------------------------------------- */
/* Transform normalized axes into unusual output coordinate axis */
/* orientation if needed. */
/* -------------------------------------------------------------------- */
if( strcmp(dstdefn->axis,"enu") != 0 )
{
int err;
err = pj_adjust_axis( dstdefn->ctx, dstdefn->axis,
1, point_count, point_offset, x, y, z );
if( err != 0 )
return err;
}
return 0;
}
/************************************************************************/
/* pj_geodetic_to_geocentric() */
/************************************************************************/
int pj_geodetic_to_geocentric( double a, double es,
long point_count, int point_offset,
double *x, double *y, double *z )
{
double b;
int i;
GeocentricInfo gi;
int ret_errno = 0;
if( es == 0.0 )
b = a;
else
b = a * sqrt(1-es);
if( pj_Set_Geocentric_Parameters( &gi, a, b ) != 0 )
{
return PJD_ERR_GEOCENTRIC;
}
for( i = 0; i < point_count; i++ )
{
long io = i * point_offset;
if( x[io] == HUGE_VAL )
continue;
if( pj_Convert_Geodetic_To_Geocentric( &gi, y[io], x[io], z[io],
x+io, y+io, z+io ) != 0 )
{
ret_errno = -14;
x[io] = y[io] = HUGE_VAL;
/* but keep processing points! */
}
}
return ret_errno;
}
/************************************************************************/
/* pj_geodetic_to_geocentric() */
/************************************************************************/
int pj_geocentric_to_geodetic( double a, double es,
long point_count, int point_offset,
double *x, double *y, double *z )
{
double b;
int i;
GeocentricInfo gi;
if( es == 0.0 )
b = a;
else
b = a * sqrt(1-es);
if( pj_Set_Geocentric_Parameters( &gi, a, b ) != 0 )
{
return PJD_ERR_GEOCENTRIC;
}
for( i = 0; i < point_count; i++ )
{
long io = i * point_offset;
if( x[io] == HUGE_VAL )
continue;
pj_Convert_Geocentric_To_Geodetic( &gi, x[io], y[io], z[io],
y+io, x+io, z+io );
}
return 0;
}
/************************************************************************/
/* pj_compare_datums() */
/* */
/* Returns TRUE if the two datums are identical, otherwise */
/* FALSE. */
/************************************************************************/
int pj_compare_datums( PJ *srcdefn, PJ *dstdefn )
{
if( srcdefn->datum_type != dstdefn->datum_type )
{
return 0;
}
else if( srcdefn->a_orig != dstdefn->a_orig
|| ABS(srcdefn->es_orig - dstdefn->es_orig) > 0.000000000050 )
{
/* the tolerence for es is to ensure that GRS80 and WGS84 are
considered identical */
return 0;
}
else if( srcdefn->datum_type == PJD_3PARAM )
{
return (srcdefn->datum_params[0] == dstdefn->datum_params[0]
&& srcdefn->datum_params[1] == dstdefn->datum_params[1]
&& srcdefn->datum_params[2] == dstdefn->datum_params[2]);
}
else if( srcdefn->datum_type == PJD_7PARAM )
{
return (srcdefn->datum_params[0] == dstdefn->datum_params[0]
&& srcdefn->datum_params[1] == dstdefn->datum_params[1]
&& srcdefn->datum_params[2] == dstdefn->datum_params[2]
&& srcdefn->datum_params[3] == dstdefn->datum_params[3]
&& srcdefn->datum_params[4] == dstdefn->datum_params[4]
&& srcdefn->datum_params[5] == dstdefn->datum_params[5]
&& srcdefn->datum_params[6] == dstdefn->datum_params[6]);
}
else if( srcdefn->datum_type == PJD_GRIDSHIFT )
{
return strcmp( pj_param(srcdefn->ctx, srcdefn->params,"snadgrids").s,
pj_param(dstdefn->ctx, dstdefn->params,"snadgrids").s ) == 0;
}
else
return 1;
}
/************************************************************************/
/* pj_geocentic_to_wgs84() */
/************************************************************************/
int pj_geocentric_to_wgs84( PJ *defn,
long point_count, int point_offset,
double *x, double *y, double *z )
{
int i;
if( defn->datum_type == PJD_3PARAM )
{
for( i = 0; i < point_count; i++ )
{
long io = i * point_offset;
if( x[io] == HUGE_VAL )
continue;
x[io] = x[io] + Dx_BF;
y[io] = y[io] + Dy_BF;
z[io] = z[io] + Dz_BF;
}
}
else if( defn->datum_type == PJD_7PARAM )
{
for( i = 0; i < point_count; i++ )
{
long io = i * point_offset;
double x_out, y_out, z_out;
if( x[io] == HUGE_VAL )
continue;
x_out = M_BF*( x[io] - Rz_BF*y[io] + Ry_BF*z[io]) + Dx_BF;
y_out = M_BF*( Rz_BF*x[io] + y[io] - Rx_BF*z[io]) + Dy_BF;
z_out = M_BF*(-Ry_BF*x[io] + Rx_BF*y[io] + z[io]) + Dz_BF;
x[io] = x_out;
y[io] = y_out;
z[io] = z_out;
}
}
return 0;
}
/************************************************************************/
/* pj_geocentic_from_wgs84() */
/************************************************************************/
int pj_geocentric_from_wgs84( PJ *defn,
long point_count, int point_offset,
double *x, double *y, double *z )
{
int i;
if( defn->datum_type == PJD_3PARAM )
{
for( i = 0; i < point_count; i++ )
{
long io = i * point_offset;
if( x[io] == HUGE_VAL )
continue;
x[io] = x[io] - Dx_BF;
y[io] = y[io] - Dy_BF;
z[io] = z[io] - Dz_BF;
}
}
else if( defn->datum_type == PJD_7PARAM )
{
for( i = 0; i < point_count; i++ )
{
long io = i * point_offset;
double x_tmp, y_tmp, z_tmp;
if( x[io] == HUGE_VAL )
continue;
x_tmp = (x[io] - Dx_BF) / M_BF;
y_tmp = (y[io] - Dy_BF) / M_BF;
z_tmp = (z[io] - Dz_BF) / M_BF;
x[io] = x_tmp + Rz_BF*y_tmp - Ry_BF*z_tmp;
y[io] = -Rz_BF*x_tmp + y_tmp + Rx_BF*z_tmp;
z[io] = Ry_BF*x_tmp - Rx_BF*y_tmp + z_tmp;
}
}
return 0;
}
/************************************************************************/
/* pj_datum_transform() */
/* */
/* The input should be long/lat/z coordinates in radians in the */
/* source datum, and the output should be long/lat/z */
/* coordinates in radians in the destination datum. */
/************************************************************************/
int pj_datum_transform( PJ *srcdefn, PJ *dstdefn,
long point_count, int point_offset,
double *x, double *y, double *z )
{
double src_a, src_es, dst_a, dst_es;
int z_is_temp = FALSE;
/* -------------------------------------------------------------------- */
/* We cannot do any meaningful datum transformation if either */
/* the source or destination are of an unknown datum type */
/* (ie. only a +ellps declaration, no +datum). This is new */
/* behavior for PROJ 4.6.0. */
/* -------------------------------------------------------------------- */
if( srcdefn->datum_type == PJD_UNKNOWN
|| dstdefn->datum_type == PJD_UNKNOWN )
return 0;
/* -------------------------------------------------------------------- */
/* Short cut if the datums are identical. */
/* -------------------------------------------------------------------- */
if( pj_compare_datums( srcdefn, dstdefn ) )
return 0;
src_a = srcdefn->a_orig;
src_es = srcdefn->es_orig;
dst_a = dstdefn->a_orig;
dst_es = dstdefn->es_orig;
/* -------------------------------------------------------------------- */
/* Create a temporary Z array if one is not provided. */
/* -------------------------------------------------------------------- */
if( z == NULL )
{
int bytes = sizeof(double) * point_count * point_offset;
z = (double *) pj_malloc(bytes);
memset( z, 0, bytes );
z_is_temp = TRUE;
}
#define CHECK_RETURN(defn) {if( defn->ctx->last_errno != 0 && (defn->ctx->last_errno > 0 || transient_error[-defn->ctx->last_errno] == 0) ) { if( z_is_temp ) pj_dalloc(z); return defn->ctx->last_errno; }}
/* -------------------------------------------------------------------- */
/* If this datum requires grid shifts, then apply it to geodetic */
/* coordinates. */
/* -------------------------------------------------------------------- */
if( srcdefn->datum_type == PJD_GRIDSHIFT )
{
pj_apply_gridshift_2( srcdefn, 0, point_count, point_offset, x, y, z );
CHECK_RETURN(srcdefn);
src_a = SRS_WGS84_SEMIMAJOR;
src_es = SRS_WGS84_ESQUARED;
}
if( dstdefn->datum_type == PJD_GRIDSHIFT )
{
dst_a = SRS_WGS84_SEMIMAJOR;
dst_es = SRS_WGS84_ESQUARED;
}
/* ==================================================================== */
/* Do we need to go through geocentric coordinates? */
/* ==================================================================== */
if( src_es != dst_es || src_a != dst_a
|| srcdefn->datum_type == PJD_3PARAM
|| srcdefn->datum_type == PJD_7PARAM
|| dstdefn->datum_type == PJD_3PARAM
|| dstdefn->datum_type == PJD_7PARAM)
{
/* -------------------------------------------------------------------- */
/* Convert to geocentric coordinates. */
/* -------------------------------------------------------------------- */
srcdefn->ctx->last_errno =
pj_geodetic_to_geocentric( src_a, src_es,
point_count, point_offset, x, y, z );
CHECK_RETURN(srcdefn);
/* -------------------------------------------------------------------- */
/* Convert between datums. */
/* -------------------------------------------------------------------- */
if( srcdefn->datum_type == PJD_3PARAM
|| srcdefn->datum_type == PJD_7PARAM )
{
pj_geocentric_to_wgs84( srcdefn, point_count, point_offset,x,y,z);
CHECK_RETURN(srcdefn);
}
if( dstdefn->datum_type == PJD_3PARAM
|| dstdefn->datum_type == PJD_7PARAM )
{
pj_geocentric_from_wgs84( dstdefn, point_count,point_offset,x,y,z);
CHECK_RETURN(dstdefn);
}
/* -------------------------------------------------------------------- */
/* Convert back to geodetic coordinates. */
/* -------------------------------------------------------------------- */
dstdefn->ctx->last_errno =
pj_geocentric_to_geodetic( dst_a, dst_es,
point_count, point_offset, x, y, z );
CHECK_RETURN(dstdefn);
}
/* -------------------------------------------------------------------- */
/* Apply grid shift to destination if required. */
/* -------------------------------------------------------------------- */
if( dstdefn->datum_type == PJD_GRIDSHIFT )
{
pj_apply_gridshift_2( dstdefn, 1, point_count, point_offset, x, y, z );
CHECK_RETURN(dstdefn);
}
if( z_is_temp )
pj_dalloc( z );
return 0;
}
/************************************************************************/
/* pj_adjust_axis() */
/* */
/* Normalize or de-normalized the x/y/z axes. The normal form */
/* is "enu" (easting, northing, up). */
/************************************************************************/
static int pj_adjust_axis( projCtx ctx,
const char *axis, int denormalize_flag,
long point_count, int point_offset,
double *x, double *y, double *z )
{
double x_in, y_in, z_in = 0.0;
int i, i_axis;
if( !denormalize_flag )
{
for( i = 0; i < point_count; i++ )
{
x_in = x[point_offset*i];
y_in = y[point_offset*i];
if( z )
z_in = z[point_offset*i];
for( i_axis = 0; i_axis < 3; i_axis++ )
{
double value;
if( i_axis == 0 )
value = x_in;
else if( i_axis == 1 )
value = y_in;
else
value = z_in;
switch( axis[i_axis] )
{
case 'e':
x[point_offset*i] = value; break;
case 'w':
x[point_offset*i] = -value; break;
case 'n':
y[point_offset*i] = value; break;
case 's':
y[point_offset*i] = -value; break;
case 'u':
if( z ) z[point_offset*i] = value; break;
case 'd':
if( z ) z[point_offset*i] = -value; break;
default:
pj_ctx_set_errno( ctx, PJD_ERR_AXIS );
return PJD_ERR_AXIS;
}
} /* i_axis */
} /* i (point) */
}
else /* denormalize */
{
for( i = 0; i < point_count; i++ )
{
x_in = x[point_offset*i];
y_in = y[point_offset*i];
if( z )
z_in = z[point_offset*i];
for( i_axis = 0; i_axis < 3; i_axis++ )
{
double *target;
if( i_axis == 2 && z == NULL )
continue;
if( i_axis == 0 )
target = x;
else if( i_axis == 1 )
target = y;
else
target = z;
switch( axis[i_axis] )
{
case 'e':
target[point_offset*i] = x_in; break;
case 'w':
target[point_offset*i] = -x_in; break;
case 'n':
target[point_offset*i] = y_in; break;
case 's':
target[point_offset*i] = -y_in; break;
case 'u':
target[point_offset*i] = z_in; break;
case 'd':
target[point_offset*i] = -z_in; break;
default:
pj_ctx_set_errno( ctx, PJD_ERR_AXIS );
return PJD_ERR_AXIS;
}
} /* i_axis */
} /* i (point) */
}
return 0;
}
proj-4.9.3/src/pj_units.c 0000644 0000000 0000000 00000002522 12761101536 012161 0000000 0000000 /* definition of standard cartesian units */
#define PJ_UNITS__
#include
/* Field 2 that contains the multiplier to convert named units to meters
** may be expressed by either a simple floating point constant or a
** numerator/denomenator values (e.g. 1/1000) */
C_NAMESPACE_VAR struct PJ_UNITS
pj_units[] = {
{"km", "1000.", "Kilometer"},
{"m", "1.", "Meter"},
{"dm", "1/10", "Decimeter"},
{"cm", "1/100", "Centimeter"},
{"mm", "1/1000", "Millimeter"},
{"kmi", "1852.0", "International Nautical Mile"},
{"in", "0.0254", "International Inch"},
{"ft", "0.3048", "International Foot"},
{"yd", "0.9144", "International Yard"},
{"mi", "1609.344", "International Statute Mile"},
{"fath", "1.8288", "International Fathom"},
{"ch", "20.1168", "International Chain"},
{"link", "0.201168", "International Link"},
{"us-in", "1./39.37", "U.S. Surveyor's Inch"},
{"us-ft", "0.304800609601219", "U.S. Surveyor's Foot"},
{"us-yd", "0.914401828803658", "U.S. Surveyor's Yard"},
{"us-ch", "20.11684023368047", "U.S. Surveyor's Chain"},
{"us-mi", "1609.347218694437", "U.S. Surveyor's Statute Mile"},
{"ind-yd", "0.91439523", "Indian Yard"},
{"ind-ft", "0.30479841", "Indian Foot"},
{"ind-ch", "20.11669506", "Indian Chain"},
{NULL, NULL, NULL}
};
struct PJ_UNITS *pj_get_units_ref()
{
return pj_units;
}
proj-4.9.3/src/PJ_stere.c 0000644 0000000 0000000 00000024755 12761101536 012055 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(stere, "Stereographic") "\n\tAzi, Sph&Ell\n\tlat_ts=";
PROJ_HEAD(ups, "Universal Polar Stereographic") "\n\tAzi, Sph&Ell\n\tsouth";
struct pj_opaque {
double phits;
double sinX1;
double cosX1;
double akm1;
int mode;
};
#define sinph0 P->opaque->sinX1
#define cosph0 P->opaque->cosX1
#define EPS10 1.e-10
#define TOL 1.e-8
#define NITER 8
#define CONV 1.e-10
#define S_POLE 0
#define N_POLE 1
#define OBLIQ 2
#define EQUIT 3
static double ssfn_ (double phit, double sinphi, double eccen) {
sinphi *= eccen;
return (tan (.5 * (M_HALFPI + phit)) *
pow ((1. - sinphi) / (1. + sinphi), .5 * eccen));
}
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double coslam, sinlam, sinX = 0.0, cosX = 0.0, X, A, sinphi;
coslam = cos (lp.lam);
sinlam = sin (lp.lam);
sinphi = sin (lp.phi);
if (Q->mode == OBLIQ || Q->mode == EQUIT) {
sinX = sin (X = 2. * atan(ssfn_(lp.phi, sinphi, P->e)) - M_HALFPI);
cosX = cos (X);
}
switch (Q->mode) {
case OBLIQ:
A = Q->akm1 / (Q->cosX1 * (1. + Q->sinX1 * sinX +
Q->cosX1 * cosX * coslam));
xy.y = A * (Q->cosX1 * sinX - Q->sinX1 * cosX * coslam);
goto xmul; /* but why not just xy.x = A * cosX; break; ? */
case EQUIT:
A = 2. * Q->akm1 / (1. + cosX * coslam);
xy.y = A * sinX;
xmul:
xy.x = A * cosX;
break;
case S_POLE:
lp.phi = -lp.phi;
coslam = - coslam;
sinphi = -sinphi;
case N_POLE:
xy.x = Q->akm1 * pj_tsfn (lp.phi, sinphi, P->e);
xy.y = - xy.x * coslam;
break;
}
xy.x = xy.x * sinlam;
return xy;
}
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double sinphi, cosphi, coslam, sinlam;
sinphi = sin(lp.phi);
cosphi = cos(lp.phi);
coslam = cos(lp.lam);
sinlam = sin(lp.lam);
switch (Q->mode) {
case EQUIT:
xy.y = 1. + cosphi * coslam;
goto oblcon;
case OBLIQ:
xy.y = 1. + sinph0 * sinphi + cosph0 * cosphi * coslam;
oblcon:
if (xy.y <= EPS10) F_ERROR;
xy.x = (xy.y = Q->akm1 / xy.y) * cosphi * sinlam;
xy.y *= (Q->mode == EQUIT) ? sinphi :
cosph0 * sinphi - sinph0 * cosphi * coslam;
break;
case N_POLE:
coslam = - coslam;
lp.phi = - lp.phi;
case S_POLE:
if (fabs (lp.phi - M_HALFPI) < TOL) F_ERROR;
xy.x = sinlam * ( xy.y = Q->akm1 * tan (M_FORTPI + .5 * lp.phi) );
xy.y *= coslam;
break;
}
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double cosphi, sinphi, tp=0.0, phi_l=0.0, rho, halfe=0.0, halfpi=0.0;
int i;
rho = hypot (xy.x, xy.y);
switch (Q->mode) {
case OBLIQ:
case EQUIT:
cosphi = cos ( tp = 2. * atan2 (rho * Q->cosX1 , Q->akm1) );
sinphi = sin (tp);
if ( rho == 0.0 )
phi_l = asin (cosphi * Q->sinX1);
else
phi_l = asin (cosphi * Q->sinX1 + (xy.y * sinphi * Q->cosX1 / rho));
tp = tan (.5 * (M_HALFPI + phi_l));
xy.x *= sinphi;
xy.y = rho * Q->cosX1 * cosphi - xy.y * Q->sinX1* sinphi;
halfpi = M_HALFPI;
halfe = .5 * P->e;
break;
case N_POLE:
xy.y = -xy.y;
case S_POLE:
phi_l = M_HALFPI - 2. * atan (tp = - rho / Q->akm1);
halfpi = -M_HALFPI;
halfe = -.5 * P->e;
break;
}
for (i = NITER; i--; phi_l = lp.phi) {
sinphi = P->e * sin(phi_l);
lp.phi = 2. * atan (tp * pow ((1.+sinphi)/(1.-sinphi), halfe)) - halfpi;
if (fabs (phi_l - lp.phi) < CONV) {
if (Q->mode == S_POLE)
lp.phi = -lp.phi;
lp.lam = (xy.x == 0. && xy.y == 0.) ? 0. : atan2 (xy.x, xy.y);
return lp;
}
}
I_ERROR;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double c, rh, sinc, cosc;
sinc = sin (c = 2. * atan ((rh = hypot (xy.x, xy.y)) / Q->akm1));
cosc = cos (c);
lp.lam = 0.;
switch (Q->mode) {
case EQUIT:
if (fabs (rh) <= EPS10)
lp.phi = 0.;
else
lp.phi = asin (xy.y * sinc / rh);
if (cosc != 0. || xy.x != 0.)
lp.lam = atan2 (xy.x * sinc, cosc * rh);
break;
case OBLIQ:
if (fabs (rh) <= EPS10)
lp.phi = P->phi0;
else
lp.phi = asin (cosc * sinph0 + xy.y * sinc * cosph0 / rh);
if ((c = cosc - sinph0 * sin (lp.phi)) != 0. || xy.x != 0.)
lp.lam = atan2 (xy.x * sinc * cosph0, c * rh);
break;
case N_POLE:
xy.y = -xy.y;
case S_POLE:
if (fabs (rh) <= EPS10)
lp.phi = P->phi0;
else
lp.phi = asin (Q->mode == S_POLE ? - cosc : cosc);
lp.lam = (xy.x == 0. && xy.y == 0.) ? 0. : atan2 (xy.x, xy.y);
break;
}
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
static PJ *setup(PJ *P) { /* general initialization */
double t;
struct pj_opaque *Q = P->opaque;
if (fabs ((t = fabs (P->phi0)) - M_HALFPI) < EPS10)
Q->mode = P->phi0 < 0. ? S_POLE : N_POLE;
else
Q->mode = t > EPS10 ? OBLIQ : EQUIT;
Q->phits = fabs (Q->phits);
if (P->es) {
double X;
switch (Q->mode) {
case N_POLE:
case S_POLE:
if (fabs (Q->phits - M_HALFPI) < EPS10)
Q->akm1 = 2. * P->k0 /
sqrt (pow (1+P->e,1+P->e) * pow (1-P->e,1-P->e));
else {
Q->akm1 = cos (Q->phits) /
pj_tsfn (Q->phits, t = sin (Q->phits), P->e);
t *= P->e;
Q->akm1 /= sqrt(1. - t * t);
}
break;
case EQUIT:
case OBLIQ:
t = sin (P->phi0);
X = 2. * atan (ssfn_(P->phi0, t, P->e)) - M_HALFPI;
t *= P->e;
Q->akm1 = 2. * P->k0 * cos (P->phi0) / sqrt(1. - t * t);
Q->sinX1 = sin (X);
Q->cosX1 = cos (X);
break;
}
P->inv = e_inverse;
P->fwd = e_forward;
} else {
switch (Q->mode) {
case OBLIQ:
sinph0 = sin (P->phi0);
cosph0 = cos (P->phi0);
case EQUIT:
Q->akm1 = 2. * P->k0;
break;
case S_POLE:
case N_POLE:
Q->akm1 = fabs (Q->phits - M_HALFPI) >= EPS10 ?
cos (Q->phits) / tan (M_FORTPI - .5 * Q->phits) :
2. * P->k0 ;
break;
}
P->inv = s_inverse;
P->fwd = s_forward;
}
return P;
}
PJ *PROJECTION(stere) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->phits = pj_param (P->ctx, P->params, "tlat_ts").i ?
pj_param (P->ctx, P->params, "rlat_ts").f : M_HALFPI;
return setup(P);
}
PJ *PROJECTION(ups) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
/* International Ellipsoid */
P->phi0 = pj_param(P->ctx, P->params, "bsouth").i ? - M_HALFPI: M_HALFPI;
if (!P->es) E_ERROR(-34);
P->k0 = .994;
P->x0 = 2000000.;
P->y0 = 2000000.;
Q->phits = M_HALFPI;
P->lam0 = 0.;
return setup(P);
}
#ifndef PJ_SELFTEST
int pj_stere_selftest (void) {return 0;}
#else
int pj_stere_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=stere +ellps=GRS80 +lat_1=0.5 +lat_2=2 +n=0.5"};
char s_args[] = {"+proj=stere +a=6400000 +lat_1=0.5 +lat_2=2 +n=0.5"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 445289.70910023432, 221221.76694834774},
{ 445289.70910023432, -221221.76694835056},
{-445289.70910023432, 221221.76694834774},
{-445289.70910023432, -221221.76694835056},
};
XY s_fwd_expect[] = {
{ 223407.81025950745, 111737.938996443},
{ 223407.81025950745, -111737.938996443},
{-223407.81025950745, 111737.938996443},
{-223407.81025950745, -111737.938996443},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.0017966305682022392, 0.00090436947502443507},
{ 0.0017966305682022392, -0.00090436947502443507},
{-0.0017966305682022392, 0.00090436947502443507},
{-0.0017966305682022392, -0.00090436947502443507},
};
LP s_inv_expect[] = {
{ 0.001790493109747395, 0.00089524655465513144},
{ 0.001790493109747395, -0.00089524655465513144},
{-0.001790493109747395, 0.00089524655465513144},
{-0.001790493109747395, -0.00089524655465513144},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_ups_selftest (void) {return 0;}
#else
int pj_ups_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=ups +ellps=GRS80 +lat_1=0.5 +lat_2=2 +n=0.5"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{2433455.5634384668, -10412543.301512826},
{2448749.1185681992, -10850493.419804076},
{1566544.4365615332, -10412543.301512826},
{1551250.8814318008, -10850493.419804076},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{-44.998567498074834, 64.9182362867341},
{-44.995702709112308, 64.917020250675748},
{-45.004297076028529, 64.915804280954518},
{-45.001432287066002, 64.914588377560719},
};
return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
}
#endif
proj-4.9.3/src/PJ_healpix.c 0000644 0000000 0000000 00000056752 12761101536 012367 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Implementation of the HEALPix and rHEALPix projections.
* For background see .
* Authors: Alex Raichev (raichev@cs.auckland.ac.nz)
* Michael Speth (spethm@landcareresearch.co.nz)
* Notes: Raichev implemented these projections in Python and
* Speth translated them into C here.
******************************************************************************
* Copyright (c) 2001, Thomas Flemming, tf@ttqv.com
*
* 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 substcounteral 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.
*****************************************************************************/
# define PJ_LIB__
# include
PROJ_HEAD(healpix, "HEALPix") "\n\tSph., Ellps.";
PROJ_HEAD(rhealpix, "rHEALPix") "\n\tSph., Ellps.\n\tnorth_square= south_square=";
# include
/* Matrix for counterclockwise rotation by pi/2: */
# define R1 {{ 0,-1},{ 1, 0}}
/* Matrix for counterclockwise rotation by pi: */
# define R2 {{-1, 0},{ 0,-1}}
/* Matrix for counterclockwise rotation by 3*pi/2: */
# define R3 {{ 0, 1},{-1, 0}}
/* Identity matrix */
# define IDENT {{1, 0},{0, 1}}
/* IDENT, R1, R2, R3, R1 inverse, R2 inverse, R3 inverse:*/
# define ROT {IDENT, R1, R2, R3, R3, R2, R1}
/* Fuzz to handle rounding errors: */
# define EPS 1e-15
struct pj_opaque {
int north_square;
int south_square;
double qp;
double *apa;
};
typedef struct {
int cn; /* An integer 0--3 indicating the position of the polar cap. */
double x, y; /* Coordinates of the pole point (point of most extreme latitude on the polar caps). */
enum Region {north, south, equatorial} region;
} CapMap;
double rot[7][2][2] = ROT;
/**
* Returns the sign of the double.
* @param v the parameter whose sign is returned.
* @return 1 for positive number, -1 for negative, and 0 for zero.
**/
double pj_sign (double v) {
return v > 0 ? 1 : (v < 0 ? -1 : 0);
}
/**
* Return the index of the matrix in ROT.
* @param index ranges from -3 to 3.
*/
static int get_rotate_index(int index) {
switch(index) {
case 0:
return 0;
case 1:
return 1;
case 2:
return 2;
case 3:
return 3;
case -1:
return 4;
case -2:
return 5;
case -3:
return 6;
}
return 0;
}
/**
* Return 1 if point (testx, testy) lies in the interior of the polygon
* determined by the vertices in vert, and return 0 otherwise.
* See http://paulbourke.net/geometry/polygonmesh/ for more details.
* @param nvert the number of vertices in the polygon.
* @param vert the (x, y)-coordinates of the polygon's vertices
**/
static int pnpoly(int nvert, double vert[][2], double testx, double testy) {
int i, c = 0;
int counter = 0;
double xinters;
XY p1, p2;
/* Check for boundrary cases */
for (i = 0; i < nvert; i++) {
if (testx == vert[i][0] && testy == vert[i][1]) {
return 1;
}
}
p1.x = vert[0][0];
p1.y = vert[0][1];
for (i = 1; i < nvert; i++) {
p2.x = vert[i % nvert][0];
p2.y = vert[i % nvert][1];
if (testy > MIN(p1.y, p2.y) &&
testy <= MAX(p1.y, p2.y) &&
testx <= MAX(p1.x, p2.x) &&
p1.y != p2.y)
{
xinters = (testy-p1.y)*(p2.x-p1.x)/(p2.y-p1.y)+p1.x;
if (p1.x == p2.x || testx <= xinters)
counter++;
}
p1 = p2;
}
if (counter % 2 == 0) {
return 0;
} else {
return 1;
}
return c;
}
/**
* Return 1 if (x, y) lies in (the interior or boundary of) the image of the
* HEALPix projection (in case proj=0) or in the image the rHEALPix projection
* (in case proj=1), and return 0 otherwise.
* @param north_square the position of the north polar square (rHEALPix only)
* @param south_square the position of the south polar square (rHEALPix only)
**/
int in_image(double x, double y, int proj, int north_square, int south_square) {
if (proj == 0) {
double healpixVertsJit[][2] = {
{-M_PI - EPS, M_FORTPI},
{-3*M_FORTPI, M_HALFPI + EPS},
{-M_HALFPI, M_FORTPI + EPS},
{-M_FORTPI, M_HALFPI + EPS},
{0.0, M_FORTPI + EPS},
{M_FORTPI, M_HALFPI + EPS},
{M_HALFPI, M_FORTPI + EPS},
{3*M_FORTPI, M_HALFPI + EPS},
{M_PI + EPS, M_FORTPI},
{M_PI + EPS, -M_FORTPI},
{3*M_FORTPI, -M_HALFPI - EPS},
{M_HALFPI, -M_FORTPI - EPS},
{M_FORTPI, -M_HALFPI - EPS},
{0.0, -M_FORTPI - EPS},
{-M_FORTPI, -M_HALFPI - EPS},
{-M_HALFPI, -M_FORTPI - EPS},
{-3*M_FORTPI, -M_HALFPI - EPS},
{-M_PI - EPS, -M_FORTPI}
};
return pnpoly((int)sizeof(healpixVertsJit)/
sizeof(healpixVertsJit[0]), healpixVertsJit, x, y);
} else {
/**
* Assigning each element by index to avoid warnings such as
* 'initializer element is not computable at load time'.
* Before C99 this was not allowed and to keep as portable as
* possible we do it the C89 way here.
* We need to assign the array this way because the input is
* dynamic (north_square and south_square vars are unknow at
* compile time).
**/
double rhealpixVertsJit[12][2];
rhealpixVertsJit[0][0] = -M_PI - EPS;
rhealpixVertsJit[0][1] = M_FORTPI + EPS;
rhealpixVertsJit[1][0] = -M_PI + north_square*M_HALFPI- EPS;
rhealpixVertsJit[1][1] = M_FORTPI + EPS;
rhealpixVertsJit[2][0] = -M_PI + north_square*M_HALFPI- EPS;
rhealpixVertsJit[2][1] = 3*M_FORTPI + EPS;
rhealpixVertsJit[3][0] = -M_PI + (north_square + 1.0)*M_HALFPI + EPS;
rhealpixVertsJit[3][1] = 3*M_FORTPI + EPS;
rhealpixVertsJit[4][0] = -M_PI + (north_square + 1.0)*M_HALFPI + EPS;
rhealpixVertsJit[4][1] = M_FORTPI + EPS;
rhealpixVertsJit[5][0] = M_PI + EPS;
rhealpixVertsJit[5][1] = M_FORTPI + EPS;
rhealpixVertsJit[6][0] = M_PI + EPS;
rhealpixVertsJit[6][1] = -M_FORTPI - EPS;
rhealpixVertsJit[7][0] = -M_PI + (south_square + 1.0)*M_HALFPI + EPS;
rhealpixVertsJit[7][1] = -M_FORTPI - EPS;
rhealpixVertsJit[8][0] = -M_PI + (south_square + 1.0)*M_HALFPI + EPS;
rhealpixVertsJit[8][1] = -3*M_FORTPI - EPS;
rhealpixVertsJit[9][0] = -M_PI + south_square*M_HALFPI - EPS;
rhealpixVertsJit[9][1] = -3*M_FORTPI - EPS;
rhealpixVertsJit[10][0] = -M_PI + south_square*M_HALFPI - EPS;
rhealpixVertsJit[10][1] = -M_FORTPI - EPS;
rhealpixVertsJit[11][0] = -M_PI - EPS;
rhealpixVertsJit[11][1] = -M_FORTPI - EPS;
return pnpoly((int)sizeof(rhealpixVertsJit)/
sizeof(rhealpixVertsJit[0]), rhealpixVertsJit, x, y);
}
}
/**
* Return the authalic latitude of latitude alpha (if inverse=0) or
* return the approximate latitude of authalic latitude alpha (if inverse=1).
* P contains the relavent ellipsoid parameters.
**/
double auth_lat(PJ *P, double alpha, int inverse) {
struct pj_opaque *Q = P->opaque;
if (inverse == 0) {
/* Authalic latitude. */
double q = pj_qsfn(sin(alpha), P->e, 1.0 - P->es);
double qp = Q->qp;
double ratio = q/qp;
if (fabsl(ratio) > 1) {
/* Rounding error. */
ratio = pj_sign(ratio);
}
return asin(ratio);
} else {
/* Approximation to inverse authalic latitude. */
return pj_authlat(alpha, Q->apa);
}
}
/**
* Return the HEALPix projection of the longitude-latitude point lp on
* the unit sphere.
**/
XY healpix_sphere(LP lp) {
double lam = lp.lam;
double phi = lp.phi;
double phi0 = asin(2.0/3.0);
XY xy;
/* equatorial region */
if ( fabsl(phi) <= phi0) {
xy.x = lam;
xy.y = 3*M_PI/8*sin(phi);
} else {
double lamc;
double sigma = sqrt(3*(1 - fabsl(sin(phi))));
double cn = floor(2*lam / M_PI + 2);
if (cn >= 4) {
cn = 3;
}
lamc = -3*M_FORTPI + M_HALFPI*cn;
xy.x = lamc + (lam - lamc)*sigma;
xy.y = pj_sign(phi)*M_FORTPI*(2 - sigma);
}
return xy;
}
/**
* Return the inverse of healpix_sphere().
**/
LP healpix_sphere_inverse(XY xy) {
LP lp;
double x = xy.x;
double y = xy.y;
double y0 = M_FORTPI;
/* Equatorial region. */
if (fabsl(y) <= y0) {
lp.lam = x;
lp.phi = asin(8*y/(3*M_PI));
} else if (fabsl(y) < M_HALFPI) {
double cn = floor(2*x/M_PI + 2);
double xc, tau;
if (cn >= 4) {
cn = 3;
}
xc = -3*M_FORTPI + M_HALFPI*cn;
tau = 2.0 - 4*fabsl(y)/M_PI;
lp.lam = xc + (x - xc)/tau;
lp.phi = pj_sign(y)*asin(1.0 - pow(tau, 2)/3.0);
} else {
lp.lam = -M_PI;
lp.phi = pj_sign(y)*M_HALFPI;
}
return (lp);
}
/**
* Return the vector sum a + b, where a and b are 2-dimensional vectors.
* @param ret holds a + b.
**/
static void vector_add(double a[2], double b[2], double *ret) {
int i;
for(i = 0; i < 2; i++) {
ret[i] = a[i] + b[i];
}
}
/**
* Return the vector difference a - b, where a and b are 2-dimensional vectors.
* @param ret holds a - b.
**/
static void vector_sub(double a[2], double b[2], double*ret) {
int i;
for(i = 0; i < 2; i++) {
ret[i] = a[i] - b[i];
}
}
/**
* Return the 2 x 1 matrix product a*b, where a is a 2 x 2 matrix and
* b is a 2 x 1 matrix.
* @param ret holds a*b.
**/
static void dot_product(double a[2][2], double b[2], double *ret) {
int i, j;
int length = 2;
for(i = 0; i < length; i++) {
ret[i] = 0;
for(j = 0; j < length; j++) {
ret[i] += a[i][j]*b[j];
}
}
}
/**
* Return the number of the polar cap, the pole point coordinates, and
* the region that (x, y) lies in.
* If inverse=0, then assume (x,y) lies in the image of the HEALPix
* projection of the unit sphere.
* If inverse=1, then assume (x,y) lies in the image of the
* (north_square, south_square)-rHEALPix projection of the unit sphere.
**/
static CapMap get_cap(double x, double y, int north_square, int south_square,
int inverse) {
CapMap capmap;
double c;
capmap.x = x;
capmap.y = y;
if (inverse == 0) {
if (y > M_FORTPI) {
capmap.region = north;
c = M_HALFPI;
} else if (y < -M_FORTPI) {
capmap.region = south;
c = -M_HALFPI;
} else {
capmap.region = equatorial;
capmap.cn = 0;
return capmap;
}
/* polar region */
if (x < -M_HALFPI) {
capmap.cn = 0;
capmap.x = (-3*M_FORTPI);
capmap.y = c;
} else if (x >= -M_HALFPI && x < 0) {
capmap.cn = 1;
capmap.x = -M_FORTPI;
capmap.y = c;
} else if (x >= 0 && x < M_HALFPI) {
capmap.cn = 2;
capmap.x = M_FORTPI;
capmap.y = c;
} else {
capmap.cn = 3;
capmap.x = 3*M_FORTPI;
capmap.y = c;
}
} else {
if (y > M_FORTPI) {
capmap.region = north;
capmap.x = -3*M_FORTPI + north_square*M_HALFPI;
capmap.y = M_HALFPI;
x = x - north_square*M_HALFPI;
} else if (y < -M_FORTPI) {
capmap.region = south;
capmap.x = -3*M_FORTPI + south_square*M_HALFPI;
capmap.y = -M_HALFPI;
x = x - south_square*M_HALFPI;
} else {
capmap.region = equatorial;
capmap.cn = 0;
return capmap;
}
/* Polar Region, find the HEALPix polar cap number that
x, y moves to when rHEALPix polar square is disassembled. */
if (capmap.region == north) {
if (y >= -x - M_FORTPI - EPS && y < x + 5*M_FORTPI - EPS) {
capmap.cn = (north_square + 1) % 4;
} else if (y > -x -M_FORTPI + EPS && y >= x + 5*M_FORTPI - EPS) {
capmap.cn = (north_square + 2) % 4;
} else if (y <= -x -M_FORTPI + EPS && y > x + 5*M_FORTPI + EPS) {
capmap.cn = (north_square + 3) % 4;
} else {
capmap.cn = north_square;
}
} else if (capmap.region == south) {
if (y <= x + M_FORTPI + EPS && y > -x - 5*M_FORTPI + EPS) {
capmap.cn = (south_square + 1) % 4;
} else if (y < x + M_FORTPI - EPS && y <= -x - 5*M_FORTPI + EPS) {
capmap.cn = (south_square + 2) % 4;
} else if (y >= x + M_FORTPI - EPS && y < -x - 5*M_FORTPI - EPS) {
capmap.cn = (south_square + 3) % 4;
} else {
capmap.cn = south_square;
}
}
}
return capmap;
}
/**
* Rearrange point (x, y) in the HEALPix projection by
* combining the polar caps into two polar squares.
* Put the north polar square in position north_square and
* the south polar square in position south_square.
* If inverse=1, then uncombine the polar caps.
* @param north_square integer between 0 and 3.
* @param south_square integer between 0 and 3.
**/
static XY combine_caps(double x, double y, int north_square, int south_square,
int inverse) {
XY xy;
double v[2];
double a[2];
double c[2];
double vector[2];
double v_min_c[2];
double ret_dot[2];
double (*tmpRot)[2];
int pole = 0;
CapMap capmap = get_cap(x, y, north_square, south_square, inverse);
if (capmap.region == equatorial) {
xy.x = capmap.x;
xy.y = capmap.y;
return xy;
}
v[0] = x; v[1] = y;
c[0] = capmap.x; c[1] = capmap.y;
if (inverse == 0) {
/* Rotate (x, y) about its polar cap tip and then translate it to
north_square or south_square. */
a[0] = -3*M_FORTPI + pole*M_HALFPI;
a[1] = M_HALFPI;
if (capmap.region == north) {
pole = north_square;
tmpRot = rot[get_rotate_index(capmap.cn - pole)];
} else {
pole = south_square;
tmpRot = rot[get_rotate_index(-1*(capmap.cn - pole))];
}
} else {
/* Inverse function.
Unrotate (x, y) and then translate it back. */
a[0] = -3*M_FORTPI + capmap.cn*M_HALFPI;
a[1] = M_HALFPI;
/* disassemble */
if (capmap.region == north) {
pole = north_square;
tmpRot = rot[get_rotate_index(-1*(capmap.cn - pole))];
} else {
pole = south_square;
tmpRot = rot[get_rotate_index(capmap.cn - pole)];
}
}
vector_sub(v, c, v_min_c);
dot_product(tmpRot, v_min_c, ret_dot);
vector_add(ret_dot, a, vector);
xy.x = vector[0];
xy.y = vector[1];
return xy;
}
static XY s_healpix_forward(LP lp, PJ *P) { /* sphere */
(void) P;
return healpix_sphere(lp);
}
static XY e_healpix_forward(LP lp, PJ *P) { /* ellipsoid */
lp.phi = auth_lat(P, lp.phi, 0);
return healpix_sphere(lp);
}
static LP s_healpix_inverse(XY xy, PJ *P) { /* sphere */
/* Check whether (x, y) lies in the HEALPix image */
if (in_image(xy.x, xy.y, 0, 0, 0) == 0) {
LP lp = {HUGE_VAL, HUGE_VAL};
pj_ctx_set_errno(P->ctx, -15);
return lp;
}
return healpix_sphere_inverse(xy);
}
static LP e_healpix_inverse(XY xy, PJ *P) { /* ellipsoid */
LP lp = {0.0,0.0};
/* Check whether (x, y) lies in the HEALPix image. */
if (in_image(xy.x, xy.y, 0, 0, 0) == 0) {
lp.lam = HUGE_VAL;
lp.phi = HUGE_VAL;
pj_ctx_set_errno(P->ctx, -15);
return lp;
}
lp = healpix_sphere_inverse(xy);
lp.phi = auth_lat(P, lp.phi, 1);
return lp;
}
static XY s_rhealpix_forward(LP lp, PJ *P) { /* sphere */
struct pj_opaque *Q = P->opaque;
XY xy = healpix_sphere(lp);
return combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 0);
}
static XY e_rhealpix_forward(LP lp, PJ *P) { /* ellipsoid */
struct pj_opaque *Q = P->opaque;
XY xy;
lp.phi = auth_lat(P, lp.phi, 0);
xy = healpix_sphere(lp);
return combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 0);
}
static LP s_rhealpix_inverse(XY xy, PJ *P) { /* sphere */
struct pj_opaque *Q = P->opaque;
/* Check whether (x, y) lies in the rHEALPix image. */
if (in_image(xy.x, xy.y, 1, Q->north_square, Q->south_square) == 0) {
LP lp = {HUGE_VAL, HUGE_VAL};
pj_ctx_set_errno(P->ctx, -15);
return lp;
}
xy = combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 1);
return healpix_sphere_inverse(xy);
}
static LP e_rhealpix_inverse(XY xy, PJ *P) { /* ellipsoid */
struct pj_opaque *Q = P->opaque;
LP lp = {0.0,0.0};
/* Check whether (x, y) lies in the rHEALPix image. */
if (in_image(xy.x, xy.y, 1, Q->north_square, Q->south_square) == 0) {
lp.lam = HUGE_VAL;
lp.phi = HUGE_VAL;
pj_ctx_set_errno(P->ctx, -15);
return lp;
}
xy = combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 1);
lp = healpix_sphere_inverse(xy);
lp.phi = auth_lat(P, lp.phi, 1);
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
if (P->opaque->apa)
pj_dealloc(P->opaque->apa);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(healpix) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
if (P->es) {
Q->apa = pj_authset(P->es); /* For auth_lat(). */
Q->qp = pj_qsfn(1.0, P->e, P->one_es); /* For auth_lat(). */
P->a = P->a*sqrt(0.5*Q->qp); /* Set P->a to authalic radius. */
P->ra = 1.0/P->a;
P->fwd = e_healpix_forward;
P->inv = e_healpix_inverse;
} else {
P->fwd = s_healpix_forward;
P->inv = s_healpix_inverse;
}
return P;
}
PJ *PROJECTION(rhealpix) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->north_square = pj_param(P->ctx, P->params,"inorth_square").i;
Q->south_square = pj_param(P->ctx, P->params,"isouth_square").i;
/* Check for valid north_square and south_square inputs. */
if (Q->north_square < 0 || Q->north_square > 3) {
E_ERROR(-47);
}
if (Q->south_square < 0 || Q->south_square > 3) {
E_ERROR(-47);
}
if (P->es) {
Q->apa = pj_authset(P->es); /* For auth_lat(). */
Q->qp = pj_qsfn(1.0, P->e, P->one_es); /* For auth_lat(). */
P->a = P->a*sqrt(0.5*Q->qp); /* Set P->a to authalic radius. */
P->ra = 1.0/P->a;
P->fwd = e_rhealpix_forward;
P->inv = e_rhealpix_inverse;
} else {
P->fwd = s_rhealpix_forward;
P->inv = s_rhealpix_inverse;
}
return P;
}
#ifndef PJ_SELFTEST
int pj_healpix_selftest (void) {return 0;}
#else
int pj_healpix_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=healpix +ellps=GRS80 +lat_1=0.5 +lat_2=2"};
char s_args[] = {"+proj=healpix +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222390.10394923863, 130406.58866448226},
{ 222390.10394923863, -130406.58866448054},
{-222390.10394923863, 130406.58866448226},
{-222390.10394923863, -130406.58866448054},
};
XY s_fwd_expect[] = {
{ 223402.14425527418, 131588.04444199943},
{ 223402.14425527418, -131588.04444199943},
{-223402.14425527418, 131588.04444199943},
{-223402.14425527418, -131588.04444199943},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.0017986411845524453, 0.00076679453057823619},
{ 0.0017986411845524453, -0.00076679453057823619},
{-0.0017986411845524453, 0.00076679453057823619},
{-0.0017986411845524453, -0.00076679453057823619},
};
LP s_inv_expect[] = {
{ 0.0017904931097838226, 0.00075990887733981202},
{ 0.0017904931097838226, -0.00075990887733981202},
{-0.0017904931097838226, 0.00075990887733981202},
{-0.0017904931097838226, -0.00075990887733981202},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_rhealpix_selftest (void) {return 0;}
#else
int pj_rhealpix_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=rhealpix +ellps=GRS80 +lat_1=0.5 +lat_2=2"};
char s_args[] = {"+proj=rhealpix +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222390.10394923863, 130406.58866448226},
{ 222390.10394923863, -130406.58866448054},
{-222390.10394923863, 130406.58866448226},
{-222390.10394923863, -130406.58866448054},
};
XY s_fwd_expect[] = {
{ 223402.14425527418, 131588.04444199943},
{ 223402.14425527418, -131588.04444199943},
{-223402.14425527418, 131588.04444199943},
{-223402.14425527418, -131588.04444199943},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.0017986411845524453, 0.00076679453057823619},
{ 0.0017986411845524453, -0.00076679453057823619},
{-0.0017986411845524453, 0.00076679453057823619},
{-0.0017986411845524453, -0.00076679453057823619},
};
LP s_inv_expect[] = {
{ 0.0017904931097838226, 0.00075990887733981202},
{ 0.0017904931097838226, -0.00075990887733981202},
{-0.0017904931097838226, 0.00075990887733981202},
{-0.0017904931097838226, -0.00075990887733981202},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
proj-4.9.3/src/pj_inv.c 0000644 0000000 0000000 00000002063 12761101536 011613 0000000 0000000 /* general inverse projection */
#define PJ_LIB__
#include
#include
# define EPS 1.0e-12
LP /* inverse projection entry */
pj_inv(XY xy, PJ *P) {
LP lp;
/* can't do as much preliminary checking as with forward */
if (xy.x == HUGE_VAL || xy.y == HUGE_VAL) {
lp.lam = lp.phi = HUGE_VAL;
pj_ctx_set_errno( P->ctx, -15);
return lp;
}
errno = pj_errno = 0;
P->ctx->last_errno = 0;
xy.x = (xy.x * P->to_meter - P->x0) * P->ra; /* descale and de-offset */
xy.y = (xy.y * P->to_meter - P->y0) * P->ra;
/* Check for NULL pointer */
if (P->inv != NULL)
{
lp = (*P->inv)(xy, P); /* inverse project */
if (P->ctx->last_errno )
lp.lam = lp.phi = HUGE_VAL;
else {
lp.lam += P->lam0; /* reduce from del lp.lam */
if (!P->over)
lp.lam = adjlon(lp.lam); /* adjust longitude to CM */
if (P->geoc && fabs(fabs(lp.phi)-M_HALFPI) > EPS)
lp.phi = atan(P->one_es * tan(lp.phi));
}
}
else
{
lp.lam = lp.phi = HUGE_VAL;
}
return lp;
}
proj-4.9.3/src/nad2bin.c 0000644 0000000 0000000 00000031241 12761101536 011643 0000000 0000000 /* Convert bivariate ASCII NAD27 to NAD83 tables to NTv2 binary structure */
#include
#include
#include
#define PJ_LIB__
#include
#define U_SEC_TO_RAD 4.848136811095359935899141023e-12
/************************************************************************/
/* swap_words() */
/* */
/* Convert the byte order of the given word(s) in place. */
/************************************************************************/
static int byte_order_test = 1;
#define IS_LSB (((unsigned char *) (&byte_order_test))[0] == 1)
static void swap_words( void *data_in, int word_size, int word_count )
{
int word;
unsigned char *data = (unsigned char *) data_in;
for( word = 0; word < word_count; word++ )
{
int i;
for( i = 0; i < word_size/2; i++ )
{
int t;
t = data[i];
data[i] = data[word_size-i-1];
data[word_size-i-1] = t;
}
data += word_size;
}
}
/************************************************************************/
/* Usage() */
/************************************************************************/
static void Usage()
{
fprintf(stderr,
"usage: nad2bin [-f ctable/ctable2/ntv2] binary_output < ascii_source\n" );
exit(1);
}
/************************************************************************/
/* main() */
/************************************************************************/
int main(int argc, char **argv) {
struct CTABLE ct;
FLP *p, t;
size_t tsize;
int i, j, ichk;
long lam, laml, phi, phil;
FILE *fp;
const char *output_file = NULL;
const char *format = "ctable2";
const char *GS_TYPE = "SECONDS";
const char *VERSION = "";
const char *SYSTEM_F = "NAD27";
const char *SYSTEM_T = "NAD83";
const char *SUB_NAME = "";
const char *CREATED = "";
const char *UPDATED = "";
/* ==================================================================== */
/* Process arguments. */
/* ==================================================================== */
for( i = 1; i < argc; i++ )
{
if( strcmp(argv[i],"-f") == 0 && i < argc-1 )
{
format = argv[++i];
}
else if( output_file == NULL )
{
output_file = argv[i];
}
else
Usage();
}
if( output_file == NULL )
Usage();
fprintf( stdout, "Output Binary File Format: %s\n", format );
/* ==================================================================== */
/* Read the ASCII Table */
/* ==================================================================== */
memset(ct.id,0,MAX_TAB_ID);
if ( NULL == fgets(ct.id, MAX_TAB_ID, stdin) ) {
perror("fgets");
exit(1);
}
if ( EOF == scanf("%d %d %*d %lf %lf %lf %lf", &ct.lim.lam, &ct.lim.phi,
&ct.ll.lam, &ct.del.lam, &ct.ll.phi, &ct.del.phi) ) {
perror("scanf");
exit(1);
}
if (!(ct.cvs = (FLP *)malloc(tsize = ct.lim.lam * ct.lim.phi *
sizeof(FLP)))) {
perror("mem. alloc");
exit(1);
}
ct.ll.lam *= DEG_TO_RAD;
ct.ll.phi *= DEG_TO_RAD;
ct.del.lam *= DEG_TO_RAD;
ct.del.phi *= DEG_TO_RAD;
/* load table */
for (p = ct.cvs, i = 0; i < ct.lim.phi; ++i) {
if ( EOF == scanf("%d:%ld %ld", &ichk, &laml, &phil) ) {
perror("scanf on row");
exit(1);
}
if (ichk != i) {
fprintf(stderr,"format check on row\n");
exit(1);
}
t.lam = laml * U_SEC_TO_RAD;
t.phi = phil * U_SEC_TO_RAD;
*p++ = t;
for (j = 1; j < ct.lim.lam; ++j) {
if ( EOF == scanf("%ld %ld", &lam, &phi) ) {
perror("scanf on column");
exit(1);
}
t.lam = (laml += lam) * U_SEC_TO_RAD;
t.phi = (phil += phi) * U_SEC_TO_RAD;
*p++ = t;
}
}
if (feof(stdin)) {
fprintf(stderr, "premature EOF\n");
exit(1);
}
/* ==================================================================== */
/* Write out the old ctable format - this is machine and byte */
/* order specific. */
/* ==================================================================== */
if( strcmp(format,"ctable") == 0 )
{
if (!(fp = fopen(output_file, "wb"))) {
perror(output_file);
exit(2);
}
if (fwrite(&ct, sizeof(ct), 1, fp) != 1 ||
fwrite(ct.cvs, tsize, 1, fp) != 1) {
fprintf(stderr, "output failure\n");
exit(2);
}
fclose( fp );
exit(0); /* normal completion */
}
/* ==================================================================== */
/* Write out the old ctable format - this is machine and byte */
/* order specific. */
/* ==================================================================== */
if( strcmp(format,"ctable2") == 0 )
{
char header[160];
if (!(fp = fopen(output_file, "wb"))) {
perror(output_file);
exit(2);
}
assert( MAX_TAB_ID == 80 );
assert( sizeof(int) == 4 ); /* for ct.lim.lam/phi */
memset( header, 0, sizeof(header) );
memcpy( header + 0, "CTABLE V2.0 ", 16 );
memcpy( header + 16, ct.id, 80 );
memcpy( header + 96, &ct.ll.lam, 8 );
memcpy( header + 104, &ct.ll.phi, 8 );
memcpy( header + 112, &ct.del.lam, 8 );
memcpy( header + 120, &ct.del.phi, 8 );
memcpy( header + 128, &ct.lim.lam, 4 );
memcpy( header + 132, &ct.lim.phi, 4 );
/* force into LSB format */
if( !IS_LSB )
{
swap_words( header + 96, 8, 4 );
swap_words( header + 128, 4, 2 );
swap_words( ct.cvs, 4, ct.lim.lam * 2 * ct.lim.phi );
}
if( fwrite( header, sizeof(header), 1, fp ) != 1 ) {
perror( "fwrite" );
exit( 2 );
}
if (fwrite(ct.cvs, tsize, 1, fp) != 1) {
perror( "fwrite" );
exit(2);
}
fclose( fp );
exit(0); /* normal completion */
}
/* ==================================================================== */
/* Write out the NTv2 format grid shift file. */
/* ==================================================================== */
if( strcmp(format,"ntv2") == 0 )
{
if (!(fp = fopen(output_file, "wb")))
{
perror(output_file);
exit(2);
}
/* -------------------------------------------------------------------- */
/* Write the file header. */
/* -------------------------------------------------------------------- */
{
char achHeader[11*16];
memset( achHeader, 0, sizeof(achHeader) );
memcpy( achHeader + 0*16, "NUM_OREC", 8 );
achHeader[ 0*16 + 8] = 0xb;
memcpy( achHeader + 1*16, "NUM_SREC", 8 );
achHeader[ 1*16 + 8] = 0xb;
memcpy( achHeader + 2*16, "NUM_FILE", 8 );
achHeader[ 2*16 + 8] = 0x1;
memcpy( achHeader + 3*16, "GS_TYPE ", 16 );
memcpy( achHeader + 3*16+8, GS_TYPE, MIN(16,strlen(GS_TYPE)) );
memcpy( achHeader + 4*16, "VERSION ", 16 );
memcpy( achHeader + 4*16+8, VERSION, MIN(16,strlen(VERSION)) );
memcpy( achHeader + 5*16, "SYSTEM_F ", 16 );
memcpy( achHeader + 5*16+8, SYSTEM_F, MIN(16,strlen(SYSTEM_F)) );
memcpy( achHeader + 6*16, "SYSTEM_T ", 16 );
memcpy( achHeader + 6*16+8, SYSTEM_T, MIN(16,strlen(SYSTEM_T)) );
memcpy( achHeader + 7*16, "MAJOR_F ", 8);
memcpy( achHeader + 8*16, "MINOR_F ", 8 );
memcpy( achHeader + 9*16, "MAJOR_T ", 8 );
memcpy( achHeader + 10*16, "MINOR_T ", 8 );
fwrite( achHeader, 1, sizeof(achHeader), fp );
}
/* -------------------------------------------------------------------- */
/* Write the grid header. */
/* -------------------------------------------------------------------- */
{
unsigned char achHeader[11*16];
double dfValue;
int nGSCount = ct.lim.lam * ct.lim.phi;
LP ur;
ur.lam = ct.ll.lam + (ct.lim.lam-1) * ct.del.lam;
ur.phi = ct.ll.phi + (ct.lim.phi-1) * ct.del.phi;
assert( sizeof(nGSCount) == 4 );
memset( achHeader, 0, sizeof(achHeader) );
memcpy( achHeader + 0*16, "SUB_NAME ", 16 );
memcpy( achHeader + 0*16+8, SUB_NAME, MIN(16,strlen(SUB_NAME)) );
memcpy( achHeader + 1*16, "PARENT ", 16 );
memcpy( achHeader + 1*16+8, "NONE", MIN(16,strlen("NONE")) );
memcpy( achHeader + 2*16, "CREATED ", 16 );
memcpy( achHeader + 2*16+8, CREATED, MIN(16,strlen(CREATED)) );
memcpy( achHeader + 3*16, "UPDATED ", 16 );
memcpy( achHeader + 3*16+8, UPDATED, MIN(16,strlen(UPDATED)) );
memcpy( achHeader + 4*16, "S_LAT ", 8 );
dfValue = ct.ll.phi * 3600.0 / DEG_TO_RAD;
memcpy( achHeader + 4*16 + 8, &dfValue, 8 );
memcpy( achHeader + 5*16, "N_LAT ", 8 );
dfValue = ur.phi * 3600.0 / DEG_TO_RAD;
memcpy( achHeader + 5*16 + 8, &dfValue, 8 );
memcpy( achHeader + 6*16, "E_LONG ", 8 );
dfValue = -1 * ur.lam * 3600.0 / DEG_TO_RAD;
memcpy( achHeader + 6*16 + 8, &dfValue, 8 );
memcpy( achHeader + 7*16, "W_LONG ", 8 );
dfValue = -1 * ct.ll.lam * 3600.0 / DEG_TO_RAD;
memcpy( achHeader + 7*16 + 8, &dfValue, 8 );
memcpy( achHeader + 8*16, "LAT_INC ", 8 );
dfValue = ct.del.phi * 3600.0 / DEG_TO_RAD;
memcpy( achHeader + 8*16 + 8, &dfValue, 8 );
memcpy( achHeader + 9*16, "LONG_INC", 8 );
dfValue = ct.del.lam * 3600.0 / DEG_TO_RAD;
memcpy( achHeader + 9*16 + 8, &dfValue, 8 );
memcpy( achHeader + 10*16, "GS_COUNT", 8 );
memcpy( achHeader + 10*16+8, &nGSCount, 4 );
if( !IS_LSB )
{
swap_words( achHeader + 4*16 + 8, 8, 1 );
swap_words( achHeader + 5*16 + 8, 8, 1 );
swap_words( achHeader + 6*16 + 8, 8, 1 );
swap_words( achHeader + 7*16 + 8, 8, 1 );
swap_words( achHeader + 8*16 + 8, 8, 1 );
swap_words( achHeader + 9*16 + 8, 8, 1 );
swap_words( achHeader + 10*16 + 8, 4, 1 );
}
fwrite( achHeader, 1, sizeof(achHeader), fp );
}
/* -------------------------------------------------------------------- */
/* Write the actual grid cells. */
/* -------------------------------------------------------------------- */
{
float *row_buf;
int row;
row_buf = (float *) pj_malloc(ct.lim.lam * sizeof(float) * 4);
memset( row_buf, 0, sizeof(float)*4 );
for( row = 0; row < ct.lim.phi; row++ )
{
int i;
for( i = 0; i < ct.lim.lam; i++ )
{
FLP *cvs = ct.cvs + (row) * ct.lim.lam
+ (ct.lim.lam - i - 1);
/* convert radians to seconds */
row_buf[i*4+0] = cvs->phi * (3600.0 / (M_PI/180.0));
row_buf[i*4+1] = cvs->lam * (3600.0 / (M_PI/180.0));
/* We leave the accuracy values as zero */
}
if( !IS_LSB )
swap_words( row_buf, 4, ct.lim.lam * 4 );
if( fwrite( row_buf, sizeof(float), ct.lim.lam*4, fp )
!= (size_t)( 4 * ct.lim.lam ) )
{
perror( "write()" );
exit( 2 );
}
}
}
fclose( fp );
exit(0); /* normal completion */
}
fprintf( stderr, "Unsupported format, nothing written.\n" );
exit( 3 );
}
proj-4.9.3/src/PJ_misrsom.c 0000644 0000000 0000000 00000021045 12761101536 012411 0000000 0000000 /******************************************************************************
* This implements Space Oblique Mercator (SOM) projection, used by the
* Multi-angle Imaging SpectroRadiometer (MISR) products, from the NASA EOS Terra
* platform.
*
* The code is identical to that of Landsat SOM (PJ_lsat.c) with the following
* parameter changes:
*
* inclination angle = 98.30382 degrees
* period of revolution = 98.88 minutes
* ascending longitude = 129.3056 degrees - (360 / 233) * path_number
*
* and the following code change:
*
* Q->rlm = PI * (1. / 248. + .5161290322580645);
*
* changed to:
*
* Q->rlm = 0
*
*****************************************************************************/
/* based upon Snyder and Linck, USGS-NMD */
#define PJ_LIB__
#include
PROJ_HEAD(misrsom, "Space oblique for MISR")
"\n\tCyl, Sph&Ell\n\tpath=";
#define TOL 1e-7
struct pj_opaque {
double a2, a4, b, c1, c3;
double q, t, u, w, p22, sa, ca, xj, rlm, rlm2;
};
static void seraz0(double lam, double mult, PJ *P) {
struct pj_opaque *Q = P->opaque;
double sdsq, h, s, fc, sd, sq, d__1;
lam *= DEG_TO_RAD;
sd = sin(lam);
sdsq = sd * sd;
s = Q->p22 * Q->sa * cos(lam) * sqrt((1. + Q->t * sdsq) / ((
1. + Q->w * sdsq) * (1. + Q->q * sdsq)));
d__1 = 1. + Q->q * sdsq;
h = sqrt((1. + Q->q * sdsq) / (1. + Q->w * sdsq)) * ((1. +
Q->w * sdsq) / (d__1 * d__1) - Q->p22 * Q->ca);
sq = sqrt(Q->xj * Q->xj + s * s);
Q->b += fc = mult * (h * Q->xj - s * s) / sq;
Q->a2 += fc * cos(lam + lam);
Q->a4 += fc * cos(lam * 4.);
fc = mult * s * (h + Q->xj) / sq;
Q->c1 += fc * cos(lam);
Q->c3 += fc * cos(lam * 3.);
}
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
int l, nn;
double lamt, xlam, sdsq, c, d, s, lamdp, phidp, lampp, tanph;
double lamtp, cl, sd, sp, fac, sav, tanphi;
if (lp.phi > M_HALFPI)
lp.phi = M_HALFPI;
else if (lp.phi < -M_HALFPI)
lp.phi = -M_HALFPI;
lampp = lp.phi >= 0. ? M_HALFPI : M_PI_HALFPI;
tanphi = tan(lp.phi);
for (nn = 0;;) {
sav = lampp;
lamtp = lp.lam + Q->p22 * lampp;
cl = cos(lamtp);
if (fabs(cl) < TOL)
lamtp -= TOL;
fac = lampp - sin(lampp) * (cl < 0. ? -M_HALFPI : M_HALFPI);
for (l = 50; l; --l) {
lamt = lp.lam + Q->p22 * sav;
if (fabs(c = cos(lamt)) < TOL)
lamt -= TOL;
xlam = (P->one_es * tanphi * Q->sa + sin(lamt) * Q->ca) / c;
lamdp = atan(xlam) + fac;
if (fabs(fabs(sav) - fabs(lamdp)) < TOL)
break;
sav = lamdp;
}
if (!l || ++nn >= 3 || (lamdp > Q->rlm && lamdp < Q->rlm2))
break;
if (lamdp <= Q->rlm)
lampp = M_TWOPI_HALFPI;
else if (lamdp >= Q->rlm2)
lampp = M_HALFPI;
}
if (l) {
sp = sin(lp.phi);
phidp = aasin(P->ctx,(P->one_es * Q->ca * sp - Q->sa * cos(lp.phi) *
sin(lamt)) / sqrt(1. - P->es * sp * sp));
tanph = log(tan(M_FORTPI + .5 * phidp));
sd = sin(lamdp);
sdsq = sd * sd;
s = Q->p22 * Q->sa * cos(lamdp) * sqrt((1. + Q->t * sdsq)
/ ((1. + Q->w * sdsq) * (1. + Q->q * sdsq)));
d = sqrt(Q->xj * Q->xj + s * s);
xy.x = Q->b * lamdp + Q->a2 * sin(2. * lamdp) + Q->a4 *
sin(lamdp * 4.) - tanph * s / d;
xy.y = Q->c1 * sd + Q->c3 * sin(lamdp * 3.) + tanph * Q->xj / d;
} else
xy.x = xy.y = HUGE_VAL;
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
int nn;
double lamt, sdsq, s, lamdp, phidp, sppsq, dd, sd, sl, fac, scl, sav, spp;
lamdp = xy.x / Q->b;
nn = 50;
do {
sav = lamdp;
sd = sin(lamdp);
sdsq = sd * sd;
s = Q->p22 * Q->sa * cos(lamdp) * sqrt((1. + Q->t * sdsq)
/ ((1. + Q->w * sdsq) * (1. + Q->q * sdsq)));
lamdp = xy.x + xy.y * s / Q->xj - Q->a2 * sin(
2. * lamdp) - Q->a4 * sin(lamdp * 4.) - s / Q->xj * (
Q->c1 * sin(lamdp) + Q->c3 * sin(lamdp * 3.));
lamdp /= Q->b;
} while (fabs(lamdp - sav) >= TOL && --nn);
sl = sin(lamdp);
fac = exp(sqrt(1. + s * s / Q->xj / Q->xj) * (xy.y -
Q->c1 * sl - Q->c3 * sin(lamdp * 3.)));
phidp = 2. * (atan(fac) - M_FORTPI);
dd = sl * sl;
if (fabs(cos(lamdp)) < TOL)
lamdp -= TOL;
spp = sin(phidp);
sppsq = spp * spp;
lamt = atan(((1. - sppsq * P->rone_es) * tan(lamdp) *
Q->ca - spp * Q->sa * sqrt((1. + Q->q * dd) * (
1. - sppsq) - sppsq * Q->u) / cos(lamdp)) / (1. - sppsq
* (1. + Q->u)));
sl = lamt >= 0. ? 1. : -1.;
scl = cos(lamdp) >= 0. ? 1. : -1;
lamt -= M_HALFPI * (1. - scl) * sl;
lp.lam = lamt - Q->p22 * lamdp;
if (fabs(Q->sa) < TOL)
lp.phi = aasin(P->ctx,spp / sqrt(P->one_es * P->one_es + P->es * sppsq));
else
lp.phi = atan((tan(lamdp) * cos(lamt) - Q->ca * sin(lamt)) /
(P->one_es * Q->sa));
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(misrsom) {
int path;
double lam, alf, esc, ess;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
path = pj_param(P->ctx, P->params, "ipath").i;
if (path <= 0 || path > 233) E_ERROR(-29);
P->lam0 = DEG_TO_RAD * 129.3056 - M_TWOPI / 233. * path;
alf = 98.30382 * DEG_TO_RAD;
Q->p22 = 98.88 / 1440.0;
Q->sa = sin(alf);
Q->ca = cos(alf);
if (fabs(Q->ca) < 1e-9)
Q->ca = 1e-9;
esc = P->es * Q->ca * Q->ca;
ess = P->es * Q->sa * Q->sa;
Q->w = (1. - esc) * P->rone_es;
Q->w = Q->w * Q->w - 1.;
Q->q = ess * P->rone_es;
Q->t = ess * (2. - P->es) * P->rone_es * P->rone_es;
Q->u = esc * P->rone_es;
Q->xj = P->one_es * P->one_es * P->one_es;
Q->rlm = 0;
Q->rlm2 = Q->rlm + M_TWOPI;
Q->a2 = Q->a4 = Q->b = Q->c1 = Q->c3 = 0.;
seraz0(0., 1., P);
for (lam = 9.; lam <= 81.0001; lam += 18.)
seraz0(lam, 4., P);
for (lam = 18; lam <= 72.0001; lam += 18.)
seraz0(lam, 2., P);
seraz0(90., 1., P);
Q->a2 /= 30.;
Q->a4 /= 60.;
Q->b /= 30.;
Q->c1 /= 15.;
Q->c3 /= 45.;
P->inv = e_inverse;
P->fwd = e_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_misrsom_selftest (void) {return 0;}
#else
int pj_misrsom_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=misrsom +ellps=GRS80 +lat_1=0.5 +lat_2=2 +path=1"};
char s_args[] = {"+proj=misrsom +a=6400000 +lat_1=0.5 +lat_2=2 +path=1"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{18556630.3683698252, 9533394.6753112711},
{19041866.0067297369, 9707182.17532352544},
{18816810.1301847994, 8647669.64980295487},
{19252610.7845367305, 8778164.08580140397},
};
XY s_fwd_expect[] = {
{18641249.2791703865, 9563342.53233416565},
{19130982.4615812786, 9739539.59350463562},
{18903483.5150115378, 8675064.50061797537},
{19343388.3998006098, 8807471.90406848863},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{127.759503987730625, 0.00173515039622462014},
{127.761295471077958, 0.00187196632421706517},
{127.759775773557251, -0.00187196632421891525},
{127.76156725690457, -0.00173515039622462014},
};
LP s_inv_expect[] = {
{127.75950514818588, 0.00171623111593511971},
{127.761290323778738, 0.00185412132880796244},
{127.759780920856471, -0.00185412132880796244},
{127.761566096449329, -0.00171623111593511971},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
proj-4.9.3/src/bin_proj.cmake 0000644 0000000 0000000 00000000644 12761101536 012771 0000000 0000000 set(PROJ_SRC proj.c
gen_cheb.c
p_series.c)
source_group("Source Files\\Bin" FILES ${PROJ_SRC})
if(WIN32)
set(PROJ_SRC ${PROJ_SRC} emess.c)
endif(WIN32)
#Executable
add_executable(binproj ${PROJ_SRC})
set_target_properties(binproj
PROPERTIES
OUTPUT_NAME proj)
target_link_libraries(binproj ${PROJ_LIBRARIES})
install(TARGETS binproj
RUNTIME DESTINATION ${BINDIR})
proj-4.9.3/src/PJ_airy.c 0000644 0000000 0000000 00000011271 12761101536 011664 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Implementation of the airy (Airy) projection.
* Author: Gerald Evenden (1995)
* Thomas Knudsen (2016) - revise/add regression tests
*
******************************************************************************
* Copyright (c) 1995, Gerald Evenden
*
* 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.
*****************************************************************************/
#define PJ_LIB__
#include
PROJ_HEAD(airy, "Airy") "\n\tMisc Sph, no inv.\n\tno_cut lat_b=";
struct pj_opaque {
double p_halfpi;
double sinph0;
double cosph0;
double Cb;
int mode;
int no_cut; /* do not cut at hemisphere limit */
};
# define EPS 1.e-10
# define N_POLE 0
# define S_POLE 1
# define EQUIT 2
# define OBLIQ 3
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double sinlam, coslam, cosphi, sinphi, t, s, Krho, cosz;
sinlam = sin(lp.lam);
coslam = cos(lp.lam);
switch (Q->mode) {
case EQUIT:
case OBLIQ:
sinphi = sin(lp.phi);
cosphi = cos(lp.phi);
cosz = cosphi * coslam;
if (Q->mode == OBLIQ)
cosz = Q->sinph0 * sinphi + Q->cosph0 * cosz;
if (!Q->no_cut && cosz < -EPS)
F_ERROR;
if (fabs(s = 1. - cosz) > EPS) {
t = 0.5 * (1. + cosz);
Krho = -log(t)/s - Q->Cb / t;
} else
Krho = 0.5 - Q->Cb;
xy.x = Krho * cosphi * sinlam;
if (Q->mode == OBLIQ)
xy.y = Krho * (Q->cosph0 * sinphi -
Q->sinph0 * cosphi * coslam);
else
xy.y = Krho * sinphi;
break;
case S_POLE:
case N_POLE:
lp.phi = fabs(Q->p_halfpi - lp.phi);
if (!Q->no_cut && (lp.phi - EPS) > M_HALFPI)
F_ERROR;
if ((lp.phi *= 0.5) > EPS) {
t = tan(lp.phi);
Krho = -2.*(log(cos(lp.phi)) / t + t * Q->Cb);
xy.x = Krho * sinlam;
xy.y = Krho * coslam;
if (Q->mode == N_POLE)
xy.y = -xy.y;
} else
xy.x = xy.y = 0.;
}
return xy;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(airy) {
double beta;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->no_cut = pj_param(P->ctx, P->params, "bno_cut").i;
beta = 0.5 * (M_HALFPI - pj_param(P->ctx, P->params, "rlat_b").f);
if (fabs(beta) < EPS)
Q->Cb = -0.5;
else {
Q->Cb = 1./tan(beta);
Q->Cb *= Q->Cb * log(cos(beta));
}
if (fabs(fabs(P->phi0) - M_HALFPI) < EPS)
if (P->phi0 < 0.) {
Q->p_halfpi = -M_HALFPI;
Q->mode = S_POLE;
} else {
Q->p_halfpi = M_HALFPI;
Q->mode = N_POLE;
}
else {
if (fabs(P->phi0) < EPS)
Q->mode = EQUIT;
else {
Q->mode = OBLIQ;
Q->sinph0 = sin(P->phi0);
Q->cosph0 = cos(P->phi0);
}
}
P->fwd = s_forward;
P->es = 0.;
return P;
}
#ifndef PJ_SELFTEST
int pj_airy_selftest (void) {return 0;}
#else
int pj_airy_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=airy +a=6400000 +lat_1=0 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 189109.88690862127, 94583.752387504152},
{ 189109.88690862127, -94583.752387504152},
{-189109.88690862127, 94583.752387504152},
{-189109.88690862127, -94583.752387504152},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 0, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/projects.h 0000644 0000000 0000000 00000047277 12761101536 012204 0000000 0000000 /******************************************************************************
* 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
/* enable predefined math constants M_* for MS Visual Studio workaround */
# define _USE_MATH_DEFINES
#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
/* If we still haven't got M_PI*, we rely on our own defines.
* For example, this is necessary when compiling with gcc and
* the -ansi flag.
*/
#ifndef M_PI
#define M_PI 3.14159265358979310
#define M_PI_2 1.57079632679489660
#define M_PI_4 0.78539816339744828
#endif
/* some more useful math constants and aliases */
#define M_FORTPI M_PI_4 /* pi/4 */
#define M_HALFPI M_PI_2 /* pi/2 */
#define M_PI_HALFPI 4.71238898038468985769 /* 1.5*pi */
#define M_TWOPI 6.28318530717958647693 /* 2*pi */
#define M_TWO_D_PI M_2_PI /* 2/pi */
#define M_TWOPI_HALFPI 7.85398163397448309616 /* 2.5*pi */
/* 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
struct projFileAPI_t;
/* proj thread context */
typedef struct {
int last_errno;
int debug_level;
void (*logger)(void *, int, const char *);
void *app_data;
struct projFileAPI_t *fileapi;
} 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 PJD_ERR_CATALOG -49
#define USE_PROJUV
typedef struct { double u, v; } projUV;
typedef struct { double r, i; } COMPLEX;
typedef struct { double u, v, w; } projUVW;
#ifndef PJ_LIB__
#define XY projUV
#define LP projUV
#define XYZ projUVW
#define LPZ projUVW
#else
typedef struct { double x, y; } XY;
typedef struct { double lam, phi; } LP;
typedef struct { double x, y, z; } XYZ;
typedef struct { double lam, phi, z; } LPZ;
#endif
typedef union { double f; int i; char *s; } PROJVALUE;
struct PJconsts;
struct PJ_LIST {
char *id; /* projection keyword */
struct PJconsts *(*proj)(struct PJconsts*); /* projection entry point */
char * const *descr; /* description text */
};
/* Merging this into the PJ_LIST infrastructure is tempting, but may imply ABI breakage. Perhaps at next major version? */
struct PJ_SELFTEST_LIST {
char *id; /* projection keyword */
int (* testfunc)(void); /* projection entry point */
};
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. */
};
typedef struct {
double ll_long; /* lower left corner coordinates (radians) */
double ll_lat;
double ur_long; /* upper right corner coordinates (radians) */
double ur_lat;
} PJ_Region;
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 */
#ifdef PJ_LIB__
/* we need this forward declaration in order to be able to add a
pointer to struct opaque to the typedef struct PJconsts below */
struct pj_opaque;
#endif
typedef struct PJconsts {
projCtx_t *ctx;
XY (*fwd)(LP, struct PJconsts *);
LP (*inv)(XY, struct PJconsts *);
XYZ (*fwd3d)(LPZ, struct PJconsts *);
LPZ (*inv3d)(XYZ, 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 */
double a_orig; /* major axis before any +proj related adjustment */
double es; /* e ^ 2 */
double es_orig; /* es before any +proj related adjustment */
double e; /* eccentricity */
double ra; /* 1/A */
double one_es; /* 1 - e^2 */
double rone_es; /* 1/one_es */
double lam0, phi0; /* central longitude, latitude */
double x0, y0; /* easting and northing */
double k0; /* general scaling factor */
double 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];
/* New Datum Shift Grid Catalogs */
char *catalog_name;
struct _PJ_GridCatalog *catalog;
double datum_date;
struct _pj_gi *last_before_grid;
PJ_Region last_before_region;
double last_before_date;
struct _pj_gi *last_after_grid;
PJ_Region last_after_region;
double last_after_date;
#ifdef PJ_LIB__
struct pj_opaque *opaque;
#endif
#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 USE_PJ_LIST_H
extern struct PJ_LIST pj_list[];
extern struct PJ_SELFTEST_LIST pj_selftest_list[];
#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__
/* repetitive 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->fwd3d = 0; P->inv3d = 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 F3_ERROR { pj_ctx_set_errno( P->ctx, -20); return(xyz); }
#define I_ERROR { pj_ctx_set_errno( P->ctx, -20); return(lp); }
#define I3_ERROR { pj_ctx_set_errno( P->ctx, -20); return(lpz); }
#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 FORWARD3D(name) static XYZ name(LPZ lpz, PJ *P) {XYZ xyz = {0.0, 0.0, 0.0}
#define INVERSE3D(name) static LPZ name(XYZ xyz, PJ *P) {LPZ lpz = {0.0, 0.0, 0.0}
#define FREEUP static void freeup(PJ *P) {
#define SPECIAL(name) static void name(LP lp, PJ *P, struct FACTORS *fac)
#define ELLIPSOIDAL(P) ((P->es==0)? (FALSE): (TRUE))
/* cleaned up alternative to most of the "repetitive projection code" macros */
#define PROJECTION(name) \
pj_projection_specific_setup_##name (PJ *P); \
C_NAMESPACE_VAR const char * const pj_s_##name = des_##name; \
C_NAMESPACE PJ *pj_##name (PJ *P) { \
if (P) \
return pj_projection_specific_setup_##name (P); \
P = (PJ*) pj_calloc (1, sizeof(PJ)); \
if (0==P) \
return 0; \
P->pfree = freeup; \
P->descr = des_##name; \
return P; \
} \
PJ *pj_projection_specific_setup_##name (PJ *P)
#endif
int pj_generic_selftest (
char *e_args,
char *s_args,
double tolerance_xy,
double tolerance_lp,
int n_fwd,
int n_inv,
LP *fwd_in,
XY *e_fwd_expect,
XY *s_fwd_expect,
XY *inv_in,
LP *e_inv_expect,
LP *s_inv_expect
);
#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 */
int must_swap; /* only for NTv2 */
struct CTABLE *ct;
struct _pj_gi *next;
struct _pj_gi *child;
} PJ_GRIDINFO;
typedef struct {
PJ_Region region;
int priority; /* higher used before lower */
double date; /* year.fraction */
char *definition; /* usually the gridname */
PJ_GRIDINFO *gridinfo;
int available; /* 0=unknown, 1=true, -1=false */
} PJ_GridCatalogEntry;
typedef struct _PJ_GridCatalog {
char *catalog_name;
PJ_Region region; /* maximum extent of catalog data */
int entry_count;
PJ_GridCatalogEntry *entries;
struct _PJ_GridCatalog *next;
} PJ_GridCatalog;
/* 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);
PROJVALUE 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 *);
void pj_prepare (PJ *P, const char *description, void (*freeup)(struct PJconsts *), size_t sizeof_struct_opaque);
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 *);
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, PAFile fid );
int nad_ctable_load( projCtx ctx, struct CTABLE *, PAFile fid );
struct CTABLE *nad_ctable2_init( projCtx ctx, PAFile fid );
int nad_ctable2_load( projCtx ctx, struct CTABLE *, PAFile 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 * );
PJ_GridCatalog *pj_gc_findcatalog( projCtx, const char * );
PJ_GridCatalog *pj_gc_readcatalog( projCtx, const char * );
void pj_gc_unloadall( projCtx );
int pj_gc_apply_gridshift( PJ *defn, int inverse,
long point_count, int point_offset,
double *x, double *y, double *z );
int pj_gc_apply_gridshift( PJ *defn, int inverse,
long point_count, int point_offset,
double *x, double *y, double *z );
PJ_GRIDINFO *pj_gc_findgrid( projCtx ctx,
PJ_GridCatalog *catalog, int after,
LP location, double date,
PJ_Region *optional_region,
double *grid_date );
double pj_gc_parsedate( projCtx, const char * );
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_SELFTEST_LIST *pj_get_selftest_list_ref ( void );
struct PJ_PRIME_MERIDIANS *pj_get_prime_meridians_ref( void );
double pj_atof( const char* nptr );
double pj_strtod( const char *nptr, char **endptr );
#ifdef __cplusplus
}
#endif
#endif /* end of basic projections header */
proj-4.9.3/src/PJ_mill.c 0000644 0000000 0000000 00000003577 12761101536 011667 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(mill, "Miller Cylindrical") "\n\tCyl, Sph";
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
(void) P;
xy.x = lp.lam;
xy.y = log(tan(M_FORTPI + lp.phi * .4)) * 1.25;
return (xy);
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
(void) P;
lp.lam = xy.x;
lp.phi = 2.5 * (atan(exp(.8 * xy.y)) - M_FORTPI);
return (lp);
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(mill) {
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_mill_selftest (void) {return 0;}
#else
int pj_mill_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=mill +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223402.144255274179, 111704.701754393827},
{ 223402.144255274179, -111704.701754396243},
{-223402.144255274179, 111704.701754393827},
{-223402.144255274179, -111704.701754396243},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00179049310978382265, 0.000895246554873922024},
{ 0.00179049310978382265, -0.000895246554873922024},
{-0.00179049310978382265, 0.000895246554873922024},
{-0.00179049310978382265, -0.000895246554873922024},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_wink2.c 0000644 0000000 0000000 00000003725 12761101536 011757 0000000 0000000 #define PJ_LIB__
# include
PROJ_HEAD(wink2, "Winkel II") "\n\tPCyl., Sph., no inv.\n\tlat_1=";
struct pj_opaque { double cosphi1; };
#define MAX_ITER 10
#define LOOP_TOL 1e-7
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0, 0.0};
double k, V;
int i;
xy.y = lp.phi * M_TWO_D_PI;
k = M_PI * sin (lp.phi);
lp.phi *= 1.8;
for (i = MAX_ITER; i ; --i) {
lp.phi -= V = (lp.phi + sin (lp.phi) - k) /
(1. + cos (lp.phi));
if (fabs (V) < LOOP_TOL)
break;
}
if (!i)
lp.phi = (lp.phi < 0.) ? -M_HALFPI : M_HALFPI;
else
lp.phi *= 0.5;
xy.x = 0.5 * lp.lam * (cos (lp.phi) + P->opaque->cosphi1);
xy.y = M_FORTPI * (sin (lp.phi) + xy.y);
return xy;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(wink2) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
P->opaque->cosphi1 = cos(pj_param(P->ctx, P->params, "rlat_1").f);
P->es = 0.;
P->inv = 0;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_wink2_selftest (void) {return 0;}
#else
int pj_wink2_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=wink2 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223387.39643378611, 124752.03279744535},
{ 223387.39643378611, -124752.03279744535},
{-223387.39643378611, 124752.03279744535},
{-223387.39643378611, -124752.03279744535},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/PJ_nocol.c 0000644 0000000 0000000 00000004302 12761101536 012027 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(nicol, "Nicolosi Globular") "\n\tMisc Sph, no inv.";
#define EPS 1e-10
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
(void) P;
if (fabs(lp.lam) < EPS) {
xy.x = 0;
xy.y = lp.phi;
} else if (fabs(lp.phi) < EPS) {
xy.x = lp.lam;
xy.y = 0.;
} else if (fabs(fabs(lp.lam) - M_HALFPI) < EPS) {
xy.x = lp.lam * cos(lp.phi);
xy.y = M_HALFPI * sin(lp.phi);
} else if (fabs(fabs(lp.phi) - M_HALFPI) < EPS) {
xy.x = 0;
xy.y = lp.phi;
} else {
double tb, c, d, m, n, r2, sp;
tb = M_HALFPI / lp.lam - lp.lam / M_HALFPI;
c = lp.phi / M_HALFPI;
d = (1 - c * c)/((sp = sin(lp.phi)) - c);
r2 = tb / d;
r2 *= r2;
m = (tb * sp / d - 0.5 * tb)/(1. + r2);
n = (sp / r2 + 0.5 * d)/(1. + 1./r2);
xy.x = cos(lp.phi);
xy.x = sqrt(m * m + xy.x * xy.x / (1. + r2));
xy.x = M_HALFPI * ( m + (lp.lam < 0. ? -xy.x : xy.x));
xy.y = sqrt(n * n - (sp * sp / r2 + d * sp - 1.) /
(1. + 1./r2));
xy.y = M_HALFPI * ( n + (lp.phi < 0. ? xy.y : -xy.y ));
}
return (xy);
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(nicol) {
P->es = 0.;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_nicol_selftest (void) {return 0;}
#else
int pj_nicol_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=nicol +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223374.561814139714, 111732.553988545071},
{ 223374.561814139714, -111732.553988545071},
{-223374.561814139714, 111732.553988545071},
{-223374.561814139714, -111732.553988545071},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/pj_gridlist.c 0000644 0000000 0000000 00000017566 12761101536 012656 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Code to manage the list of currently loaded (cached) PJ_GRIDINFOs
* See pj_gridinfo.c for details of loading individual grids.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* 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.
*****************************************************************************/
#define PJ_LIB__
#include
#include
#include
#ifdef _WIN32_WCE
/* assert.h includes all Windows API headers and causes 'LP' name clash.
* Here assert we disable assert() for Windows CE.
* TODO - mloskot: re-implement porting friendly assert
*/
# define assert(exp) ((void)0)
#else
# include
#endif /* _WIN32_WCE */
static PJ_GRIDINFO *grid_list = NULL;
#define PJ_MAX_PATH_LENGTH 1024
/************************************************************************/
/* pj_deallocate_grids() */
/* */
/* Deallocate all loaded grids. */
/************************************************************************/
void pj_deallocate_grids()
{
while( grid_list != NULL )
{
PJ_GRIDINFO *item = grid_list;
grid_list = grid_list->next;
item->next = NULL;
pj_gridinfo_free( pj_get_default_ctx(), item );
}
}
/************************************************************************/
/* pj_gridlist_merge_grid() */
/* */
/* Find/load the named gridfile and merge it into the */
/* last_nadgrids_list. */
/************************************************************************/
static int pj_gridlist_merge_gridfile( projCtx ctx,
const char *gridname,
PJ_GRIDINFO ***p_gridlist,
int *p_gridcount,
int *p_gridmax )
{
int got_match=0;
PJ_GRIDINFO *this_grid, *tail = NULL;
/* -------------------------------------------------------------------- */
/* Try to find in the existing list of loaded grids. Add all */
/* matching grids as with NTv2 we can get many grids from one */
/* file (one shared gridname). */
/* -------------------------------------------------------------------- */
for( this_grid = grid_list; this_grid != NULL; this_grid = this_grid->next)
{
if( strcmp(this_grid->gridname,gridname) == 0 )
{
got_match = 1;
/* dont add to the list if it is invalid. */
if( this_grid->ct == NULL )
return 0;
/* do we need to grow the list? */
if( *p_gridcount >= *p_gridmax - 2 )
{
PJ_GRIDINFO **new_list;
int new_max = *p_gridmax + 20;
new_list = (PJ_GRIDINFO **) pj_malloc(sizeof(void*) * new_max);
if( *p_gridlist != NULL )
{
memcpy( new_list, *p_gridlist,
sizeof(void*) * (*p_gridmax) );
pj_dalloc( *p_gridlist );
}
*p_gridlist = new_list;
*p_gridmax = new_max;
}
/* add to the list */
(*p_gridlist)[(*p_gridcount)++] = this_grid;
(*p_gridlist)[*p_gridcount] = NULL;
}
tail = this_grid;
}
if( got_match )
return 1;
/* -------------------------------------------------------------------- */
/* Try to load the named grid. */
/* -------------------------------------------------------------------- */
this_grid = pj_gridinfo_init( ctx, gridname );
if( this_grid == NULL )
{
/* we should get at least a stub grid with a missing "ct" member */
assert( FALSE );
return 0;
}
if( tail != NULL )
tail->next = this_grid;
else
grid_list = this_grid;
/* -------------------------------------------------------------------- */
/* Recurse to add the grid now that it is loaded. */
/* -------------------------------------------------------------------- */
return pj_gridlist_merge_gridfile( ctx, gridname, p_gridlist,
p_gridcount, p_gridmax );
}
/************************************************************************/
/* pj_gridlist_from_nadgrids() */
/* */
/* This functions loads the list of grids corresponding to a */
/* particular nadgrids string into a list, and returns it. The */
/* list is kept around till a request is made with a different */
/* string in order to cut down on the string parsing cost, and */
/* the cost of building the list of tables each time. */
/************************************************************************/
PJ_GRIDINFO **pj_gridlist_from_nadgrids( projCtx ctx, const char *nadgrids,
int *grid_count)
{
const char *s;
PJ_GRIDINFO **gridlist = NULL;
int grid_max = 0;
pj_errno = 0;
*grid_count = 0;
pj_acquire_lock();
/* -------------------------------------------------------------------- */
/* Loop processing names out of nadgrids one at a time. */
/* -------------------------------------------------------------------- */
for( s = nadgrids; *s != '\0'; )
{
size_t end_char;
int required = 1;
char name[PJ_MAX_PATH_LENGTH];
if( *s == '@' )
{
required = 0;
s++;
}
for( end_char = 0;
s[end_char] != '\0' && s[end_char] != ',';
end_char++ ) {}
if( end_char >= sizeof(name) )
{
pj_ctx_set_errno( ctx, -38 );
pj_release_lock();
return NULL;
}
strncpy( name, s, end_char );
name[end_char] = '\0';
s += end_char;
if( *s == ',' )
s++;
if( !pj_gridlist_merge_gridfile( ctx, name, &gridlist, grid_count,
&grid_max)
&& required )
{
pj_ctx_set_errno( ctx, -38 );
pj_release_lock();
return NULL;
}
else
pj_errno = 0;
}
pj_release_lock();
return gridlist;
}
proj-4.9.3/src/geodtest.c 0000644 0000000 0000000 00000072661 12761101536 012157 0000000 0000000 /**
* \file geodtest.c
* \brief Test suite for the geodesic routines in C
*
* Run these tests by configuring with cmake and running "make test".
*
* Copyright (c) Charles Karney (2015-2016) and licensed
* under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/
**********************************************************************/
/** @cond SKIP */
#include "geodesic.h"
#include
#include
#if defined(_MSC_VER)
// Squelch warnings about assignment within conditional expression
# pragma warning (disable: 4706)
#endif
double wgs84_a = 6378137, wgs84_f = 1/298.257223563; /* WGS84 */
int assertEquals(double x, double y, double d) {
if (fabs(x - y) <= d)
return 0;
printf("assertEquals fails: %.7g != %.7g +/- %.7g\n", x, y, d);
return 1;
}
const int ncases = 20;
double testcases[20][12] = {
{35.60777, -139.44815, 111.098748429560326,
-11.17491, -69.95921, 129.289270889708762,
8935244.5604818305, 80.50729714281974, 6273170.2055303837,
0.16606318447386067, 0.16479116945612937, 12841384694976.432},
{55.52454, 106.05087, 22.020059880982801,
77.03196, 197.18234, 109.112041110671519,
4105086.1713924406, 36.892740690445894, 3828869.3344387607,
0.80076349608092607, 0.80101006984201008, 61674961290615.615},
{-21.97856, 142.59065, -32.44456876433189,
41.84138, 98.56635, -41.84359951440466,
8394328.894657671, 75.62930491011522, 6161154.5773110616,
0.24816339233950381, 0.24930251203627892, -6637997720646.717},
{-66.99028, 112.2363, 173.73491240878403,
-12.70631, 285.90344, 2.512956620913668,
11150344.2312080241, 100.278634181155759, 6289939.5670446687,
-0.17199490274700385, -0.17722569526345708, -121287239862139.744},
{-17.42761, 173.34268, -159.033557661192928,
-15.84784, 5.93557, -20.787484651536988,
16076603.1631180673, 144.640108810286253, 3732902.1583877189,
-0.81273638700070476, -0.81299800519154474, 97825992354058.708},
{32.84994, 48.28919, 150.492927788121982,
-56.28556, 202.29132, 48.113449399816759,
16727068.9438164461, 150.565799985466607, 3147838.1910180939,
-0.87334918086923126, -0.86505036767110637, -72445258525585.010},
{6.96833, 52.74123, 92.581585386317712,
-7.39675, 206.17291, 90.721692165923907,
17102477.2496958388, 154.147366239113561, 2772035.6169917581,
-0.89991282520302447, -0.89986892177110739, -1311796973197.995},
{-50.56724, -16.30485, -105.439679907590164,
-33.56571, -94.97412, -47.348547835650331,
6455670.5118668696, 58.083719495371259, 5409150.7979815838,
0.53053508035997263, 0.52988722644436602, 41071447902810.047},
{-58.93002, -8.90775, 140.965397902500679,
-8.91104, 133.13503, 19.255429433416599,
11756066.0219864627, 105.755691241406877, 6151101.2270708536,
-0.26548622269867183, -0.27068483874510741, -86143460552774.735},
{-68.82867, -74.28391, 93.774347763114881,
-50.63005, -8.36685, 34.65564085411343,
3956936.926063544, 35.572254987389284, 3708890.9544062657,
0.81443963736383502, 0.81420859815358342, -41845309450093.787},
{-10.62672, -32.0898, -86.426713286747751,
5.883, -134.31681, -80.473780971034875,
11470869.3864563009, 103.387395634504061, 6184411.6622659713,
-0.23138683500430237, -0.23155097622286792, 4198803992123.548},
{-21.76221, 166.90563, 29.319421206936428,
48.72884, 213.97627, 43.508671946410168,
9098627.3986554915, 81.963476716121964, 6299240.9166992283,
0.13965943368590333, 0.14152969707656796, 10024709850277.476},
{-19.79938, -174.47484, 71.167275780171533,
-11.99349, -154.35109, 65.589099775199228,
2319004.8601169389, 20.896611684802389, 2267960.8703918325,
0.93427001867125849, 0.93424887135032789, -3935477535005.785},
{-11.95887, -116.94513, 92.712619830452549,
4.57352, 7.16501, 78.64960934409585,
13834722.5801401374, 124.688684161089762, 5228093.177931598,
-0.56879356755666463, -0.56918731952397221, -9919582785894.853},
{-87.85331, 85.66836, -65.120313040242748,
66.48646, 16.09921, -4.888658719272296,
17286615.3147144645, 155.58592449699137, 2635887.4729110181,
-0.90697975771398578, -0.91095608883042767, 42667211366919.534},
{1.74708, 128.32011, -101.584843631173858,
-11.16617, 11.87109, -86.325793296437476,
12942901.1241347408, 116.650512484301857, 5682744.8413270572,
-0.44857868222697644, -0.44824490340007729, 10763055294345.653},
{-25.72959, -144.90758, -153.647468693117198,
-57.70581, -269.17879, -48.343983158876487,
9413446.7452453107, 84.664533838404295, 6356176.6898881281,
0.09492245755254703, 0.09737058264766572, 74515122850712.444},
{-41.22777, 122.32875, 14.285113402275739,
-7.57291, 130.37946, 10.805303085187369,
3812686.035106021, 34.34330804743883, 3588703.8812128856,
0.82605222593217889, 0.82572158200920196, -2456961531057.857},
{11.01307, 138.25278, 79.43682622782374,
6.62726, 247.05981, 103.708090215522657,
11911190.819018408, 107.341669954114577, 6070904.722786735,
-0.29767608923657404, -0.29785143390252321, 17121631423099.696},
{-29.47124, 95.14681, -163.779130441688382,
-27.46601, -69.15955, -15.909335945554969,
13487015.8381145492, 121.294026715742277, 5481428.9945736388,
-0.51527225545373252, -0.51556587964721788, 104679964020340.318}};
int testinverse() {
double lat1, lon1, azi1, lat2, lon2, azi2, s12, a12, m12, M12, M21, S12;
double azi1a, azi2a, s12a, a12a, m12a, M12a, M21a, S12a;
struct geod_geodesic g;
int i, result = 0;
geod_init(&g, wgs84_a, wgs84_f);
for (i = 0; i < ncases; ++i) {
lat1 = testcases[i][0]; lon1 = testcases[i][1]; azi1 = testcases[i][2];
lat2 = testcases[i][3]; lon2 = testcases[i][4]; azi2 = testcases[i][5];
s12 = testcases[i][6]; a12 = testcases[i][7]; m12 = testcases[i][8];
M12 = testcases[i][9]; M21 = testcases[i][10]; S12 = testcases[i][11];
a12a = geod_geninverse(&g, lat1, lon1, lat2, lon2, &s12a, &azi1a, &azi2a,
&m12a, &M12a, &M21a, &S12a);
result += assertEquals(azi1, azi1a, 1e-13);
result += assertEquals(azi2, azi2a, 1e-13);
result += assertEquals(s12, s12a, 1e-8);
result += assertEquals(a12, a12a, 1e-13);
result += assertEquals(m12, m12a, 1e-8);
result += assertEquals(M12, M12a, 1e-15);
result += assertEquals(M21, M21a, 1e-15);
result += assertEquals(S12, S12a, 0.1);
}
return result;
}
int testdirect() {
double lat1, lon1, azi1, lat2, lon2, azi2, s12, a12, m12, M12, M21, S12;
double lat2a, lon2a, azi2a, a12a, m12a, M12a, M21a, S12a;
struct geod_geodesic g;
int i, result = 0;
unsigned flags = GEOD_LONG_UNROLL;
geod_init(&g, wgs84_a, wgs84_f);
for (i = 0; i < ncases; ++i) {
lat1 = testcases[i][0]; lon1 = testcases[i][1]; azi1 = testcases[i][2];
lat2 = testcases[i][3]; lon2 = testcases[i][4]; azi2 = testcases[i][5];
s12 = testcases[i][6]; a12 = testcases[i][7]; m12 = testcases[i][8];
M12 = testcases[i][9]; M21 = testcases[i][10]; S12 = testcases[i][11];
a12a = geod_gendirect(&g, lat1, lon1, azi1, flags, s12,
&lat2a, &lon2a, &azi2a, 0,
&m12a, &M12a, &M21a, &S12a);
result += assertEquals(lat2, lat2a, 1e-13);
result += assertEquals(lon2, lon2a, 1e-13);
result += assertEquals(azi2, azi2a, 1e-13);
result += assertEquals(a12, a12a, 1e-13);
result += assertEquals(m12, m12a, 1e-8);
result += assertEquals(M12, M12a, 1e-15);
result += assertEquals(M21, M21a, 1e-15);
result += assertEquals(S12, S12a, 0.1);
}
return result;
}
int testarcdirect() {
double lat1, lon1, azi1, lat2, lon2, azi2, s12, a12, m12, M12, M21, S12;
double lat2a, lon2a, azi2a, s12a, m12a, M12a, M21a, S12a;
struct geod_geodesic g;
int i, result = 0;
unsigned flags = GEOD_ARCMODE | GEOD_LONG_UNROLL;
geod_init(&g, wgs84_a, wgs84_f);
for (i = 0; i < ncases; ++i) {
lat1 = testcases[i][0]; lon1 = testcases[i][1]; azi1 = testcases[i][2];
lat2 = testcases[i][3]; lon2 = testcases[i][4]; azi2 = testcases[i][5];
s12 = testcases[i][6]; a12 = testcases[i][7]; m12 = testcases[i][8];
M12 = testcases[i][9]; M21 = testcases[i][10]; S12 = testcases[i][11];
geod_gendirect(&g, lat1, lon1, azi1, flags, a12,
&lat2a, &lon2a, &azi2a, &s12a, &m12a, &M12a, &M21a, &S12a);
result += assertEquals(lat2, lat2a, 1e-13);
result += assertEquals(lon2, lon2a, 1e-13);
result += assertEquals(azi2, azi2a, 1e-13);
result += assertEquals(s12, s12a, 1e-8);
result += assertEquals(m12, m12a, 1e-8);
result += assertEquals(M12, M12a, 1e-15);
result += assertEquals(M21, M21a, 1e-15);
result += assertEquals(S12, S12a, 0.1);
}
return result;
}
int GeodSolve0() {
double azi1, azi2, s12;
struct geod_geodesic g;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_inverse(&g, 40.6, -73.8, 49.01666667, 2.55, &s12, &azi1, &azi2);
result += assertEquals(azi1, 53.47022, 0.5e-5);
result += assertEquals(azi2, 111.59367, 0.5e-5);
result += assertEquals(s12, 5853226, 0.5);
return result;
}
int GeodSolve1() {
double lat2, lon2, azi2;
struct geod_geodesic g;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_direct(&g, 40.63972222, -73.77888889, 53.5, 5850e3,
&lat2, &lon2, &azi2);
result += assertEquals(lat2, 49.01467, 0.5e-5);
result += assertEquals(lon2, 2.56106, 0.5e-5);
result += assertEquals(azi2, 111.62947, 0.5e-5);
return result;
}
int GeodSolve2() {
/* Check fix for antipodal prolate bug found 2010-09-04 */
double azi1, azi2, s12;
struct geod_geodesic g;
int result = 0;
geod_init(&g, 6.4e6, -1/150.0);
geod_inverse(&g, 0.07476, 0, -0.07476, 180, &s12, &azi1, &azi2);
result += assertEquals(azi1, 90.00078, 0.5e-5);
result += assertEquals(azi2, 90.00078, 0.5e-5);
result += assertEquals(s12, 20106193, 0.5);
geod_inverse(&g, 0.1, 0, -0.1, 180, &s12, &azi1, &azi2);
result += assertEquals(azi1, 90.00105, 0.5e-5);
result += assertEquals(azi2, 90.00105, 0.5e-5);
result += assertEquals(s12, 20106193, 0.5);
return result;
}
int GeodSolve4() {
/* Check fix for short line bug found 2010-05-21 */
double s12;
struct geod_geodesic g;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_inverse(&g, 36.493349428792, 0, 36.49334942879201, .0000008,
&s12, 0, 0);
result += assertEquals(s12, 0.072, 0.5e-3);
return result;
}
int GeodSolve5() {
/* Check fix for point2=pole bug found 2010-05-03 */
double lat2, lon2, azi2;
struct geod_geodesic g;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_direct(&g, 0.01777745589997, 30, 0, 10e6, &lat2, &lon2, &azi2);
result += assertEquals(lat2, 90, 0.5e-5);
if (lon2 < 0) {
result += assertEquals(lon2, -150, 0.5e-5);
result += assertEquals(azi2, -180, 0.5e-5);
} else {
result += assertEquals(lon2, 30, 0.5e-5);
result += assertEquals(azi2, 0, 0.5e-5);
}
return result;
}
int GeodSolve6() {
/* Check fix for volatile sbet12a bug found 2011-06-25 (gcc 4.4.4
* x86 -O3). Found again on 2012-03-27 with tdm-mingw32 (g++ 4.6.1). */
double s12;
struct geod_geodesic g;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_inverse(&g, 88.202499451857, 0,
-88.202499451857, 179.981022032992859592, &s12, 0, 0);
result += assertEquals(s12, 20003898.214, 0.5e-3);
geod_inverse(&g, 89.262080389218, 0,
-89.262080389218, 179.992207982775375662, &s12, 0, 0);
result += assertEquals(s12, 20003925.854, 0.5e-3);
geod_inverse(&g, 89.333123580033, 0,
-89.333123580032997687, 179.99295812360148422, &s12, 0, 0);
result += assertEquals(s12, 20003926.881, 0.5e-3);
return result;
}
int GeodSolve9() {
/* Check fix for volatile x bug found 2011-06-25 (gcc 4.4.4 x86 -O3) */
double s12;
struct geod_geodesic g;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_inverse(&g, 56.320923501171, 0,
-56.320923501171, 179.664747671772880215, &s12, 0, 0);
result += assertEquals(s12, 19993558.287, 0.5e-3);
return result;
}
int GeodSolve10() {
/* Check fix for adjust tol1_ bug found 2011-06-25 (Visual Studio
* 10 rel + debug) */
double s12;
struct geod_geodesic g;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_inverse(&g, 52.784459512564, 0,
-52.784459512563990912, 179.634407464943777557, &s12, 0, 0);
result += assertEquals(s12, 19991596.095, 0.5e-3);
return result;
}
int GeodSolve11() {
/* Check fix for bet2 = -bet1 bug found 2011-06-25 (Visual Studio
* 10 rel + debug) */
double s12;
struct geod_geodesic g;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_inverse(&g, 48.522876735459, 0,
-48.52287673545898293, 179.599720456223079643, &s12, 0, 0);
result += assertEquals(s12, 19989144.774, 0.5e-3);
return result;
}
int GeodSolve12() {
/* Check fix for inverse geodesics on extreme prolate/oblate
* ellipsoids Reported 2012-08-29 Stefan Guenther
* ; fixed 2012-10-07 */
double azi1, azi2, s12;
struct geod_geodesic g;
int result = 0;
geod_init(&g, 89.8, -1.83);
geod_inverse(&g, 0, 0, -10, 160, &s12, &azi1, &azi2);
result += assertEquals(azi1, 120.27, 1e-2);
result += assertEquals(azi2, 105.15, 1e-2);
result += assertEquals(s12, 266.7, 1e-1);
return result;
}
int GeodSolve14() {
/* Check fix for inverse ignoring lon12 = nan */
double azi1, azi2, s12, nan = sqrt(-1.0);
struct geod_geodesic g;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_inverse(&g, 0, 0, 1, nan, &s12, &azi1, &azi2);
result += azi1 == azi1 ? 1 : 0;
result += azi2 == azi2 ? 1 : 0;
result += s12 == s12 ? 1 : 0;
return result;
}
int GeodSolve15() {
/* Initial implementation of Math::eatanhe was wrong for e^2 < 0. This
* checks that this is fixed. */
double S12;
struct geod_geodesic g;
int result = 0;
geod_init(&g, 6.4e6, -1/150.0);
geod_gendirect(&g, 1, 2, 3, 0, 4,
0, 0, 0, 0, 0, 0, 0, &S12);
result += assertEquals(S12, 23700, 0.5);
return result;
}
int GeodSolve17() {
/* Check fix for LONG_UNROLL bug found on 2015-05-07 */
double lat2, lon2, azi2;
struct geod_geodesic g;
struct geod_geodesicline l;
int result = 0;
unsigned flags = GEOD_LONG_UNROLL;
geod_init(&g, wgs84_a, wgs84_f);
geod_gendirect(&g, 40, -75, -10, flags, 2e7,
&lat2, &lon2, &azi2, 0, 0, 0, 0, 0);
result += assertEquals(lat2, -39, 1);
result += assertEquals(lon2, -254, 1);
result += assertEquals(azi2, -170, 1);
geod_lineinit(&l, &g, 40, -75, -10, 0);
geod_genposition(&l, flags, 2e7, &lat2, &lon2, &azi2, 0, 0, 0, 0, 0);
result += assertEquals(lat2, -39, 1);
result += assertEquals(lon2, -254, 1);
result += assertEquals(azi2, -170, 1);
geod_direct(&g, 40, -75, -10, 2e7, &lat2, &lon2, &azi2);
result += assertEquals(lat2, -39, 1);
result += assertEquals(lon2, 105, 1);
result += assertEquals(azi2, -170, 1);
geod_position(&l, 2e7, &lat2, &lon2, &azi2);
result += assertEquals(lat2, -39, 1);
result += assertEquals(lon2, 105, 1);
result += assertEquals(azi2, -170, 1);
return result;
}
int GeodSolve26() {
/* Check 0/0 problem with area calculation on sphere 2015-09-08 */
double S12;
struct geod_geodesic g;
int result = 0;
geod_init(&g, 6.4e6, 0);
geod_geninverse(&g, 1, 2, 3, 4, 0, 0, 0, 0, 0, 0, &S12);
result += assertEquals(S12, 49911046115.0, 0.5);
return result;
}
int GeodSolve28() {
/* Check for bad placement of assignment of r.a12 with |f| > 0.01 (bug in
* Java implementation fixed on 2015-05-19). */
double a12;
struct geod_geodesic g;
int result = 0;
geod_init(&g, 6.4e6, 0.1);
a12 = geod_gendirect(&g, 1, 2, 10, 0, 5e6, 0, 0, 0, 0, 0, 0, 0, 0);
result += assertEquals(a12, 48.55570690, 0.5e-8);
return result;
}
int GeodSolve33() {
/* Check max(-0.0,+0.0) issues 2015-08-22 (triggered by bugs in Octave --
* sind(-0.0) = +0.0 -- and in some version of Visual Studio --
* fmod(-0.0, 360.0) = +0.0. */
double azi1, azi2, s12;
struct geod_geodesic g;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_inverse(&g, 0, 0, 0, 179, &s12, &azi1, &azi2);
result += assertEquals(azi1, 90.00000, 0.5e-5);
result += assertEquals(azi2, 90.00000, 0.5e-5);
result += assertEquals(s12, 19926189, 0.5);
geod_inverse(&g, 0, 0, 0, 179.5, &s12, &azi1, &azi2);
result += assertEquals(azi1, 55.96650, 0.5e-5);
result += assertEquals(azi2, 124.03350, 0.5e-5);
result += assertEquals(s12, 19980862, 0.5);
geod_inverse(&g, 0, 0, 0, 180, &s12, &azi1, &azi2);
result += assertEquals(azi1, 0.00000, 0.5e-5);
result += assertEquals(azi2, -180.00000, 0.5e-5);
result += assertEquals(s12, 20003931, 0.5);
geod_inverse(&g, 0, 0, 1, 180, &s12, &azi1, &azi2);
result += assertEquals(azi1, 0.00000, 0.5e-5);
result += assertEquals(azi2, -180.00000, 0.5e-5);
result += assertEquals(s12, 19893357, 0.5);
geod_init(&g, 6.4e6, 0);
geod_inverse(&g, 0, 0, 0, 179, &s12, &azi1, &azi2);
result += assertEquals(azi1, 90.00000, 0.5e-5);
result += assertEquals(azi2, 90.00000, 0.5e-5);
result += assertEquals(s12, 19994492, 0.5);
geod_inverse(&g, 0, 0, 0, 180, &s12, &azi1, &azi2);
result += assertEquals(azi1, 0.00000, 0.5e-5);
result += assertEquals(azi2, -180.00000, 0.5e-5);
result += assertEquals(s12, 20106193, 0.5);
geod_inverse(&g, 0, 0, 1, 180, &s12, &azi1, &azi2);
result += assertEquals(azi1, 0.00000, 0.5e-5);
result += assertEquals(azi2, -180.00000, 0.5e-5);
result += assertEquals(s12, 19994492, 0.5);
geod_init(&g, 6.4e6, -1/300.0);
geod_inverse(&g, 0, 0, 0, 179, &s12, &azi1, &azi2);
result += assertEquals(azi1, 90.00000, 0.5e-5);
result += assertEquals(azi2, 90.00000, 0.5e-5);
result += assertEquals(s12, 19994492, 0.5);
geod_inverse(&g, 0, 0, 0, 180, &s12, &azi1, &azi2);
result += assertEquals(azi1, 90.00000, 0.5e-5);
result += assertEquals(azi2, 90.00000, 0.5e-5);
result += assertEquals(s12, 20106193, 0.5);
geod_inverse(&g, 0, 0, 0.5, 180, &s12, &azi1, &azi2);
result += assertEquals(azi1, 33.02493, 0.5e-5);
result += assertEquals(azi2, 146.97364, 0.5e-5);
result += assertEquals(s12, 20082617, 0.5);
geod_inverse(&g, 0, 0, 1, 180, &s12, &azi1, &azi2);
result += assertEquals(azi1, 0.00000, 0.5e-5);
result += assertEquals(azi2, -180.00000, 0.5e-5);
result += assertEquals(s12, 20027270, 0.5);
return result;
}
int GeodSolve55() {
/* Check fix for nan + point on equator or pole not returning all nans in
* Geodesic::Inverse, found 2015-09-23. */
double azi1, azi2, s12, nan = sqrt(-1.0);
struct geod_geodesic g;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_inverse(&g, nan, 0, 0, 90, &s12, &azi1, &azi2);
result += azi1 == azi1 ? 1 : 0;
result += azi2 == azi2 ? 1 : 0;
result += s12 == s12 ? 1 : 0;
geod_inverse(&g, nan, 0, 90, 9, &s12, &azi1, &azi2);
result += azi1 == azi1 ? 1 : 0;
result += azi2 == azi2 ? 1 : 0;
result += s12 == s12 ? 1 : 0;
return result;
}
int GeodSolve59() {
/* Check for points close with longitudes close to 180 deg apart. */
double azi1, azi2, s12;
struct geod_geodesic g;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_inverse(&g, 5, 0.00000000000001, 10, 180, &s12, &azi1, &azi2);
result += assertEquals(azi1, 0.000000000000035, 1.5e-14);
result += assertEquals(azi2, 179.99999999999996, 1.5e-14);
result += assertEquals(s12, 18345191.174332713, 2.5e-9);
return result;
}
int GeodSolve61() {
/* Make sure small negative azimuths are west-going */
double lat2, lon2, azi2;
struct geod_geodesic g;
struct geod_geodesicline l;
int result = 0;
unsigned flags = GEOD_LONG_UNROLL;
geod_init(&g, wgs84_a, wgs84_f);
geod_gendirect(&g, 45, 0, -0.000000000000000003, flags, 1e7,
&lat2, &lon2, &azi2, 0, 0, 0, 0, 0);
result += assertEquals(lat2, 45.30632, 0.5e-5);
result += assertEquals(lon2, -180, 0.5e-5);
result += assertEquals(azi2, -180, 0.5e-5);
geod_inverseline(&l, &g, 45, 0, 80, -0.000000000000000003, 0);
geod_genposition(&l, flags, 1e7, &lat2, &lon2, &azi2, 0, 0, 0, 0, 0);
result += assertEquals(lat2, 45.30632, 0.5e-5);
result += assertEquals(lon2, -180, 0.5e-5);
result += assertEquals(azi2, -180, 0.5e-5);
return result;
}
int GeodSolve65() {
/* Check for bug in east-going check in GeodesicLine (needed to check for
* sign of 0) and sign error in area calculation due to a bogus override of
* the code for alp12. Found/fixed on 2015-12-19. */
double lat2, lon2, azi2, s12, a12, m12, M12, M21, S12;
struct geod_geodesic g;
struct geod_geodesicline l;
int result = 0;
unsigned flags = GEOD_LONG_UNROLL, caps = GEOD_ALL;
geod_init(&g, wgs84_a, wgs84_f);
geod_inverseline(&l, &g, 30, -0.000000000000000001, -31, 180, caps);
a12 = geod_genposition(&l, flags, 1e7,
&lat2, &lon2, &azi2, &s12, &m12, &M12, &M21, &S12);
result += assertEquals(lat2, -60.23169, 0.5e-5);
result += assertEquals(lon2, -0.00000, 0.5e-5);
result += assertEquals(azi2, -180.00000, 0.5e-5);
result += assertEquals(s12, 10000000, 0.5);
result += assertEquals(a12, 90.06544, 0.5e-5);
result += assertEquals(m12, 6363636, 0.5);
result += assertEquals(M12, -0.0012834, 0.5e-7);
result += assertEquals(M21, 0.0013749, 0.5e-7);
result += assertEquals(S12, 0, 0.5);
a12 = geod_genposition(&l, flags, 2e7,
&lat2, &lon2, &azi2, &s12, &m12, &M12, &M21, &S12);
result += assertEquals(lat2, -30.03547, 0.5e-5);
result += assertEquals(lon2, -180.00000, 0.5e-5);
result += assertEquals(azi2, -0.00000, 0.5e-5);
result += assertEquals(s12, 20000000, 0.5);
result += assertEquals(a12, 179.96459, 0.5e-5);
result += assertEquals(m12, 54342, 0.5);
result += assertEquals(M12, -1.0045592, 0.5e-7);
result += assertEquals(M21, -0.9954339, 0.5e-7);
result += assertEquals(S12, 127516405431022.0, 0.5);
return result;
}
int GeodSolve67() {
/* Check for InverseLine if line is slightly west of S and that s13 is
correctly set. */
double lat2, lon2, azi2;
struct geod_geodesic g;
struct geod_geodesicline l;
int result = 0;
unsigned flags = GEOD_LONG_UNROLL;
geod_init(&g, wgs84_a, wgs84_f);
geod_inverseline(&l, &g, -5, -0.000000000000002, -10, 180, 0);
geod_genposition(&l, flags, 2e7, &lat2, &lon2, &azi2, 0, 0, 0, 0, 0);
result += assertEquals(lat2, 4.96445, 0.5e-5);
result += assertEquals(lon2, -180.00000, 0.5e-5);
result += assertEquals(azi2, -0.00000, 0.5e-5);
geod_genposition(&l, flags, 0.5 * l.s13, &lat2, &lon2, &azi2, 0, 0, 0, 0, 0);
result += assertEquals(lat2, -87.52461, 0.5e-5);
result += assertEquals(lon2, -0.00000, 0.5e-5);
result += assertEquals(azi2, -180.00000, 0.5e-5);
return result;
}
int GeodSolve71() {
/* Check that DirectLine sets s13. */
double lat2, lon2, azi2;
struct geod_geodesic g;
struct geod_geodesicline l;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_directline(&l, &g, 1, 2, 45, 1e7, 0);
geod_position(&l, 0.5 * l.s13, &lat2, &lon2, &azi2);
result += assertEquals(lat2, 30.92625, 0.5e-5);
result += assertEquals(lon2, 37.54640, 0.5e-5);
result += assertEquals(azi2, 55.43104, 0.5e-5);
return result;
}
int GeodSolve73() {
/* Check for backwards from the pole bug reported by Anon on 2016-02-13.
* This only affected the Java implementation. It was introduced in Java
* version 1.44 and fixed in 1.46-SNAPSHOT on 2016-01-17. */
double lat2, lon2, azi2;
struct geod_geodesic g;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
geod_direct(&g, 90, 10, 180, -1e6,
&lat2, &lon2, &azi2);
result += assertEquals(lat2, 81.04623, 0.5e-5);
result += assertEquals(lon2, -170, 0.5e-5);
result += assertEquals(azi2, 0, 0.5e-5);
return result;
}
void planimeter(const struct geod_geodesic* g, double points[][2], int N,
double* perimeter, double* area) {
struct geod_polygon p;
int i;
geod_polygon_init(&p, 0);
for (i = 0; i < N; ++i)
geod_polygon_addpoint(g, &p, points[i][0], points[i][1]);
geod_polygon_compute(g, &p, 0, 1, area, perimeter);
}
void polylength(const struct geod_geodesic* g, double points[][2], int N,
double* perimeter) {
struct geod_polygon p;
int i;
geod_polygon_init(&p, 1);
for (i = 0; i < N; ++i)
geod_polygon_addpoint(g, &p, points[i][0], points[i][1]);
geod_polygon_compute(g, &p, 0, 1, 0, perimeter);
}
int Planimeter0() {
/* Check fix for pole-encircling bug found 2011-03-16 */
double pa[4][2] = {{89, 0}, {89, 90}, {89, 180}, {89, 270}};
double pb[4][2] = {{-89, 0}, {-89, 90}, {-89, 180}, {-89, 270}};
double pc[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
double pd[3][2] = {{90, 0}, {0, 0}, {0, 90}};
struct geod_geodesic g;
double perimeter, area;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
planimeter(&g, pa, 4, &perimeter, &area);
result += assertEquals(perimeter, 631819.8745, 1e-4);
result += assertEquals(area, 24952305678.0, 1);
planimeter(&g, pb, 4, &perimeter, &area);
result += assertEquals(perimeter, 631819.8745, 1e-4);
result += assertEquals(area, -24952305678.0, 1);
planimeter(&g, pc, 4, &perimeter, &area);
result += assertEquals(perimeter, 627598.2731, 1e-4);
result += assertEquals(area, 24619419146.0, 1);
planimeter(&g, pd, 3, &perimeter, &area);
result += assertEquals(perimeter, 30022685, 1);
result += assertEquals(area, 63758202715511.0, 1);
polylength(&g, pd, 3, &perimeter);
result += assertEquals(perimeter, 20020719, 1);
return result;
}
int Planimeter5() {
/* Check fix for Planimeter pole crossing bug found 2011-06-24 */
double points[3][2] = {{89, 0.1}, {89, 90.1}, {89, -179.9}};
struct geod_geodesic g;
double perimeter, area;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
planimeter(&g, points, 3, &perimeter, &area);
result += assertEquals(perimeter, 539297, 1);
result += assertEquals(area, 12476152838.5, 1);
return result;
}
int Planimeter6() {
/* Check fix for Planimeter lon12 rounding bug found 2012-12-03 */
double pa[3][2] = {{9, -0.00000000000001}, {9, 180}, {9, 0}};
double pb[3][2] = {{9, 0.00000000000001}, {9, 0}, {9, 180}};
double pc[3][2] = {{9, 0.00000000000001}, {9, 180}, {9, 0}};
double pd[3][2] = {{9, -0.00000000000001}, {9, 0}, {9, 180}};
struct geod_geodesic g;
double perimeter, area;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
planimeter(&g, pa, 3, &perimeter, &area);
result += assertEquals(perimeter, 36026861, 1);
result += assertEquals(area, 0, 1);
planimeter(&g, pb, 3, &perimeter, &area);
result += assertEquals(perimeter, 36026861, 1);
result += assertEquals(area, 0, 1);
planimeter(&g, pc, 3, &perimeter, &area);
result += assertEquals(perimeter, 36026861, 1);
result += assertEquals(area, 0, 1);
planimeter(&g, pd, 3, &perimeter, &area);
result += assertEquals(perimeter, 36026861, 1);
result += assertEquals(area, 0, 1);
return result;
}
int Planimeter12() {
/* Area of arctic circle (not really -- adjunct to rhumb-area test) */
double points[2][2] = {{66.562222222, 0}, {66.562222222, 180}};
struct geod_geodesic g;
double perimeter, area;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
planimeter(&g, points, 2, &perimeter, &area);
result += assertEquals(perimeter, 10465729, 1);
result += assertEquals(area, 0, 1);
return result;
}
int Planimeter13() {
/* Check encircling pole twice */
double points[6][2] = {{89,-360}, {89,-240}, {89,-120},
{89,0}, {89,120}, {89,240}};
struct geod_geodesic g;
double perimeter, area;
int result = 0;
geod_init(&g, wgs84_a, wgs84_f);
planimeter(&g, points, 6, &perimeter, &area);
result += assertEquals(perimeter, 1160741, 1);
result += assertEquals(area, 32415230256.0, 1);
return result;
}
int main() {
int n = 0, i;
if ((i = testinverse())) {++n; printf("testinverse fail: %d\n", i);}
if ((i = testdirect())) {++n; printf("testdirect fail: %d\n", i);}
if ((i = testarcdirect())) {++n; printf("testarcdirect fail: %d\n", i);}
if ((i = GeodSolve0())) {++n; printf("GeodSolve0 fail: %d\n", i);}
if ((i = GeodSolve1())) {++n; printf("GeodSolve1 fail: %d\n", i);}
if ((i = GeodSolve2())) {++n; printf("GeodSolve2 fail: %d\n", i);}
if ((i = GeodSolve4())) {++n; printf("GeodSolve4 fail: %d\n", i);}
if ((i = GeodSolve5())) {++n; printf("GeodSolve5 fail: %d\n", i);}
if ((i = GeodSolve6())) {++n; printf("GeodSolve6 fail: %d\n", i);}
if ((i = GeodSolve9())) {++n; printf("GeodSolve9 fail: %d\n", i);}
if ((i = GeodSolve10())) {++n; printf("GeodSolve10 fail: %d\n", i);}
if ((i = GeodSolve11())) {++n; printf("GeodSolve11 fail: %d\n", i);}
if ((i = GeodSolve12())) {++n; printf("GeodSolve12 fail: %d\n", i);}
if ((i = GeodSolve14())) {++n; printf("GeodSolve14 fail: %d\n", i);}
if ((i = GeodSolve15())) {++n; printf("GeodSolve15 fail: %d\n", i);}
if ((i = GeodSolve17())) {++n; printf("GeodSolve17 fail: %d\n", i);}
if ((i = GeodSolve26())) {++n; printf("GeodSolve26 fail: %d\n", i);}
if ((i = GeodSolve28())) {++n; printf("GeodSolve28 fail: %d\n", i);}
if ((i = GeodSolve33())) {++n; printf("GeodSolve33 fail: %d\n", i);}
if ((i = GeodSolve55())) {++n; printf("GeodSolve55 fail: %d\n", i);}
if ((i = GeodSolve59())) {++n; printf("GeodSolve59 fail: %d\n", i);}
if ((i = GeodSolve61())) {++n; printf("GeodSolve61 fail: %d\n", i);}
if ((i = GeodSolve65())) {++n; printf("GeodSolve65 fail: %d\n", i);}
if ((i = GeodSolve67())) {++n; printf("GeodSolve67 fail: %d\n", i);}
if ((i = GeodSolve71())) {++n; printf("GeodSolve71 fail: %d\n", i);}
if ((i = GeodSolve73())) {++n; printf("GeodSolve73 fail: %d\n", i);}
if ((i = Planimeter0())) {++n; printf("Planimeter0 fail: %d\n", i);}
if ((i = Planimeter5())) {++n; printf("Planimeter5 fail: %d\n", i);}
if ((i = Planimeter6())) {++n; printf("Planimeter6 fail: %d\n", i);}
if ((i = Planimeter12())) {++n; printf("Planimeter12 fail: %d\n", i);}
if ((i = Planimeter13())) {++n; printf("Planimeter13 fail: %d\n", i);}
return n;
}
/** @endcond */
proj-4.9.3/src/PJ_tcea.c 0000644 0000000 0000000 00000003732 12761101536 011637 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(tcea, "Transverse Cylindrical Equal Area") "\n\tCyl, Sph";
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
xy.x = cos (lp.phi) * sin (lp.lam) / P->k0;
xy.y = P->k0 * (atan2 (tan (lp.phi), cos (lp.lam)) - P->phi0);
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0, 0.0};
double t;
xy.y = xy.y / P->k0 + P->phi0;
xy.x *= P->k0;
t = sqrt (1. - xy.x * xy.x);
lp.phi = asin (t * sin (xy.y));
lp.lam = atan2 (xy.x, t * cos (xy.y));
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(tcea) {
P->inv = s_inverse;
P->fwd = s_forward;
P->es = 0.;
return P;
}
#ifndef PJ_SELFTEST
int pj_tcea_selftest (void) {return 0;}
#else
int pj_tcea_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=tcea +a=6400000 +lat_1=0.5 +lat_2=2 +n=0.5"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223322.76057672748, 111769.14504058579},
{ 223322.76057672748, -111769.14504058579},
{-223322.76057672748, 111769.14504058579},
{-223322.76057672748, -111769.14504058579},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0017904931102938101, 0.00089524655445477922},
{ 0.0017904931102938101, -0.00089524655445477922},
{-0.0017904931102938101, 0.00089524655445477922},
{-0.0017904931102938101, -0.00089524655445477922},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_gstmerc.c 0000644 0000000 0000000 00000006317 12761101536 012371 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(gstmerc, "Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion)")
"\n\tCyl, Sph&Ell\n\tlat_0= lon_0= k_0=";
struct pj_opaque {
double lamc;
double phic;
double c;
double n1;
double n2;
double XS;
double YS;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double L, Ls, sinLs1, Ls1;
L = Q->n1*lp.lam;
Ls = Q->c + Q->n1 * log(pj_tsfn(-1.0 * lp.phi, -1.0 * sin(lp.phi), P->e));
sinLs1 = sin(L) / cosh(Ls);
Ls1 = log(pj_tsfn(-1.0 * asin(sinLs1), 0.0, 0.0));
xy.x = (Q->XS + Q->n2*Ls1) * P->ra;
xy.y = (Q->YS + Q->n2*atan(sinh(Ls) / cos(L))) * P->ra;
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double L, LC, sinC;
L = atan(sinh((xy.x * P->a - Q->XS) / Q->n2) / cos((xy.y * P->a - Q->YS) / Q->n2));
sinC = sin((xy.y * P->a - Q->YS) / Q->n2) / cosh((xy.x * P->a - Q->XS) / Q->n2);
LC = log(pj_tsfn(-1.0 * asin(sinC), 0.0, 0.0));
lp.lam = L / Q->n1;
lp.phi = -1.0 * pj_phi2(P->ctx, exp((LC - Q->c) / Q->n1), P->e);
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(gstmerc) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->lamc = P->lam0;
Q->n1 = sqrt(1.0 + P->es * pow(cos(P->phi0), 4.0) / (1.0 - P->es));
Q->phic = asin(sin(P->phi0) / Q->n1);
Q->c = log(pj_tsfn(-1.0 * Q->phic, 0.0, 0.0))
- Q->n1 * log(pj_tsfn(-1.0 * P->phi0, -1.0 * sin(P->phi0), P->e));
Q->n2 = P->k0 * P->a * sqrt(1.0 - P->es) / (1.0 - P->es * sin(P->phi0) * sin(P->phi0));
Q->XS = 0;
Q->YS = -1.0 * Q->n2 * Q->phic;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_gstmerc_selftest (void) {return 0;}
#else
int pj_gstmerc_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=gstmerc +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223413.46640632182, 111769.14504058557},
{ 223413.46640632182, -111769.14504058668},
{-223413.46640632302, 111769.14504058557},
{-223413.46640632302, -111769.14504058668},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0017904931097109673, 0.0008952465544509083},
{ 0.0017904931097109673, -0.0008952465544509083},
{-0.0017904931097109673, 0.0008952465544509083},
{-0.0017904931097109673, -0.0008952465544509083},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/pj_gauss.c 0000644 0000000 0000000 00000005250 12761101536 012142 0000000 0000000 /*
** libproj -- library of cartographic projections
**
** Copyright (c) 2003 Gerald I. Evenden
*/
/*
** 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.
*/
#define PJ_LIB__
#include
#define MAX_ITER 20
struct GAUSS {
double C;
double K;
double e;
double ratexp;
};
#define EN ((struct GAUSS *)en)
#define DEL_TOL 1e-14
static double
srat(double esinp, double exp) {
return(pow((1.-esinp)/(1.+esinp), exp));
}
void *
pj_gauss_ini(double e, double phi0, double *chi, double *rc) {
double sphi, cphi, es;
struct GAUSS *en;
if ((en = (struct GAUSS *)malloc(sizeof(struct GAUSS))) == NULL)
return (NULL);
es = e * e;
EN->e = e;
sphi = sin(phi0);
cphi = cos(phi0); cphi *= cphi;
*rc = sqrt(1. - es) / (1. - es * sphi * sphi);
EN->C = sqrt(1. + es * cphi * cphi / (1. - es));
*chi = asin(sphi / EN->C);
EN->ratexp = 0.5 * EN->C * e;
EN->K = tan(.5 * *chi + M_FORTPI) / (
pow(tan(.5 * phi0 + M_FORTPI), EN->C) *
srat(EN->e * sphi, EN->ratexp) );
return ((void *)en);
}
LP
pj_gauss(projCtx ctx, LP elp, const void *en) {
LP slp;
(void) ctx;
slp.phi = 2. * atan( EN->K *
pow(tan(.5 * elp.phi + M_FORTPI), EN->C) *
srat(EN->e * sin(elp.phi), EN->ratexp) ) - M_HALFPI;
slp.lam = EN->C * (elp.lam);
return(slp);
}
LP
pj_inv_gauss(projCtx ctx, LP slp, const void *en) {
LP elp;
double num;
int i;
elp.lam = slp.lam / EN->C;
num = pow(tan(.5 * slp.phi + M_FORTPI)/EN->K, 1./EN->C);
for (i = MAX_ITER; i; --i) {
elp.phi = 2. * atan(num * srat(EN->e * sin(slp.phi), -.5 * EN->e))
- M_HALFPI;
if (fabs(elp.phi - slp.phi) < DEL_TOL) break;
slp.phi = elp.phi;
}
/* convergence failed */
if (!i)
pj_ctx_set_errno( ctx, -17 );
return (elp);
}
proj-4.9.3/src/pj_mutex.c 0000644 0000000 0000000 00000020142 12761101536 012157 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Mutex (thread lock) functions.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2009, 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.
*****************************************************************************/
/* projects.h and windows.h conflict - avoid this! */
#if defined(MUTEX_pthread) && !defined(_XOPEN_SOURCE)
/* For pthread_mutexattr_settype */
#define _XOPEN_SOURCE 500
#endif
#ifndef _WIN32
#include "proj_config.h"
#include
#else
#include
#endif
/* on win32 we always use win32 mutexes, even if pthreads are available */
#if defined(_WIN32) && !defined(MUTEX_stub)
#ifndef MUTEX_win32
# define MUTEX_win32
#endif
# undef MUTEX_pthread
#endif
#if !defined(MUTEX_stub) && !defined(MUTEX_pthread) && !defined(MUTEX_win32)
# define MUTEX_stub
#endif
/************************************************************************/
/* ==================================================================== */
/* stub mutex implementation */
/* ==================================================================== */
/************************************************************************/
#ifdef MUTEX_stub
/************************************************************************/
/* pj_acquire_lock() */
/* */
/* Acquire the PROJ.4 lock. */
/************************************************************************/
void pj_acquire_lock()
{
}
/************************************************************************/
/* pj_release_lock() */
/* */
/* Release the PROJ.4 lock. */
/************************************************************************/
void pj_release_lock()
{
}
/************************************************************************/
/* pj_cleanup_lock() */
/************************************************************************/
void pj_cleanup_lock()
{
}
#endif /* def MUTEX_stub */
/************************************************************************/
/* ==================================================================== */
/* pthread mutex implementation */
/* ==================================================================== */
/************************************************************************/
#ifdef MUTEX_pthread
#include "pthread.h"
static pthread_mutex_t pj_precreated_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t pj_core_lock;
static int pj_core_lock_created = 0;
/************************************************************************/
/* pj_acquire_lock() */
/* */
/* Acquire the PROJ.4 lock. */
/************************************************************************/
void pj_acquire_lock()
{
if (!pj_core_lock_created) {
/*
** We need to ensure the core mutex is created in recursive mode
** and there is no portable way of doing that using automatic
** initialization so we have pj_precreated_lock only for the purpose
** of protecting the creation of the core lock.
*/
pthread_mutexattr_t mutex_attr;
pthread_mutex_lock( &pj_precreated_lock);
pthread_mutexattr_init(&mutex_attr);
#ifdef HAVE_PTHREAD_MUTEX_RECURSIVE
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE);
#else
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_RECURSIVE_NP);
#endif
pthread_mutex_init(&pj_core_lock, &mutex_attr);
pj_core_lock_created = 1;
pthread_mutex_unlock( &pj_precreated_lock );
}
pthread_mutex_lock( &pj_core_lock);
}
/************************************************************************/
/* pj_release_lock() */
/* */
/* Release the PROJ.4 lock. */
/************************************************************************/
void pj_release_lock()
{
pthread_mutex_unlock( &pj_core_lock );
}
/************************************************************************/
/* pj_cleanup_lock() */
/************************************************************************/
void pj_cleanup_lock()
{
}
#endif /* def MUTEX_pthread */
/************************************************************************/
/* ==================================================================== */
/* win32 mutex implementation */
/* ==================================================================== */
/************************************************************************/
#ifdef MUTEX_win32
#include
static HANDLE mutex_lock = NULL;
/************************************************************************/
/* pj_init_lock() */
/************************************************************************/
static void pj_init_lock()
{
if( mutex_lock == NULL )
mutex_lock = CreateMutex( NULL, FALSE, NULL );
}
/************************************************************************/
/* pj_acquire_lock() */
/* */
/* Acquire the PROJ.4 lock. */
/************************************************************************/
void pj_acquire_lock()
{
if( mutex_lock == NULL )
pj_init_lock();
WaitForSingleObject( mutex_lock, INFINITE );
}
/************************************************************************/
/* pj_release_lock() */
/* */
/* Release the PROJ.4 lock. */
/************************************************************************/
void pj_release_lock()
{
if( mutex_lock == NULL )
pj_init_lock();
else
ReleaseMutex( mutex_lock );
}
/************************************************************************/
/* pj_cleanup_lock() */
/************************************************************************/
void pj_cleanup_lock()
{
if( mutex_lock != NULL )
{
CloseHandle( mutex_lock );
mutex_lock = NULL;
}
}
#endif /* def MUTEX_win32 */
proj-4.9.3/src/proj.def 0000644 0000000 0000000 00000006765 12761101536 011631 0000000 0000000 VERSION 1.2
EXPORTS
pj_init @1
pj_fwd @2
pj_inv @3
pj_free @4
pj_transform @5
pj_geocentric_to_geodetic @6
pj_geodetic_to_geocentric @7
pj_deallocate_grids @8
pj_init_plus @9
pj_latlong_from_proj @10
pj_is_latlong @11
pj_get_errno_ref @12
pj_set_finder @13
pj_strerrno @14
pj_errno @15
pj_get_def @16
pj_dalloc @17
pj_is_geocent @18
pj_get_release @19
pj_malloc @20
pj_pr_list @21
pj_compare_datums @22
pj_apply_gridshift @23
pj_datum_transform @24
pj_set_searchpath @25
dmstor @26
pj_get_ellps_ref @27
pj_get_datums_ref @28
pj_get_units_ref @29
pj_get_list_ref @30
pj_get_prime_meridians_ref @31
rtodms @32
set_rtodms @33
pj_factors @34
mk_cheby @35
adjlon @36
pj_param @37
pj_ell_set @38
pj_mkparam @39
pj_init_ctx @40
pj_init_plus_ctx @41
pj_get_default_ctx @42
pj_get_ctx @43
pj_set_ctx @44
pj_ctx_alloc @45
pj_ctx_free @46
pj_ctx_get_errno @47
pj_ctx_set_errno @48
pj_ctx_set_debug @49
pj_ctx_set_logger @50
pj_ctx_set_app_data @51
pj_ctx_get_app_data @52
pj_log @53
pj_clear_initcache @54
geod_init @55
geod_lineinit @56
geod_genposition @57
geod_position @58
geod_gendirect @59
geod_direct @60
geod_geninverse @61
geod_inverse @62
geod_polygonarea @63
pj_get_spheroid_defn @64
pj_get_default_fileapi @65
pj_ctx_set_fileapi @66
pj_ctx_get_fileapi @67
pj_ctx_fopen @68
pj_ctx_fread @69
pj_ctx_ftell @70
pj_ctx_fclose @71
pj_open_lib @72
pj_atof @73
pj_strtod @74
pj_fwd3d @75
pj_inv3d @76
geod_gensetdistance @77
geod_setdistance @78
geod_gendirectline @79
geod_directline @80
geod_inverseline @81
geod_polygon_init @82
geod_polygon_addedge @83
geod_polygon_addpoint @84
geod_polygon_compute @85
geod_polygon_testedge @86
geod_polygon_testpoint @87
geod_polygon_clear @88
pj_run_selftests @89
proj-4.9.3/src/PJ_eck5.c 0000644 0000000 0000000 00000003713 12761101536 011551 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(eck5, "Eckert V") "\n\tPCyl, Sph.";
#define XF 0.44101277172455148219
#define RXF 2.26750802723822639137
#define YF 0.88202554344910296438
#define RYF 1.13375401361911319568
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
(void) P;
xy.x = XF * (1. + cos(lp.phi)) * lp.lam;
xy.y = YF * lp.phi;
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
(void) P;
lp.lam = RXF * xy.x / (1. + cos( lp.phi = RYF * xy.y));
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(eck5) {
P->es = 0.0;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_eck5_selftest (void) {return 0;}
#else
int pj_eck5_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=eck5 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 197031.39213406085, 98523.198847226551},
{ 197031.39213406085, -98523.198847226551},
{-197031.39213406085, 98523.198847226551},
{-197031.39213406085, -98523.198847226551},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{0.002029978749734037, 0.001014989374787388},
{0.002029978749734037, -0.001014989374787388},
{-0.002029978749734037, 0.001014989374787388},
{-0.002029978749734037, -0.001014989374787388},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/jniproj.c 0000644 0000000 0000000 00000040406 12761101536 012004 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Java/JNI wrappers for PROJ.4 API.
* Author: Antonello Andrea
* Martin Desruisseaux
*
******************************************************************************
* Copyright (c) 2005, Antonello Andrea
*
* 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.
*****************************************************************************/
/*!
* \file jniproj.c
*
* \brief
* Functions used by the Java Native Interface (JNI) wrappers of Proj.4
*
*
* \author Antonello Andrea
* \date Wed Oct 20 23:10:24 CEST 2004
*
* \author Martin Desruisseaux
* \date August 2011
*/
#include "proj_config.h"
#ifdef JNI_ENABLED
#include
#include
#include "projects.h"
#include "org_proj4_PJ.h"
#include
#define PJ_FIELD_NAME "ptr"
#define PJ_FIELD_TYPE "J"
#define PJ_MAX_DIMENSION 100
/* The PJ_MAX_DIMENSION value appears also in quoted strings.
Please perform a search-and-replace if this value is changed. */
/*!
* \brief
* Internal method returning the address of the PJ structure wrapped by the given Java object.
* This function looks for a field named "ptr" and of type "long" (Java signature "J") in the
* given object.
*
* \param env - The JNI environment.
* \param object - The Java object wrapping the PJ structure (not allowed to be NULL).
* \return The address of the PJ structure, or NULL if the operation fails (for example
* because the "ptr" field was not found).
*/
PJ *getPJ(JNIEnv *env, jobject object)
{
jfieldID id = (*env)->GetFieldID(env, (*env)->GetObjectClass(env, object), PJ_FIELD_NAME, PJ_FIELD_TYPE);
return (id) ? (PJ*) (*env)->GetLongField(env, object, id) : NULL;
}
/*!
* \brief
* Internal method returning the java.lang.Double.NaN constant value.
* Efficiency is no a high concern for this particular method, because it
* is used mostly when the user wrongly attempt to use a disposed PJ object.
*
* \param env - The JNI environment.
* \return The java.lang.Double.NaN constant value.
*/
jdouble javaNaN(JNIEnv *env)
{
jclass c = (*env)->FindClass(env, "java/lang/Double");
if (c) { // Should never be NULL, but let be paranoiac.
jfieldID id = (*env)->GetStaticFieldID(env, c, "NaN", "D");
if (id) { // Should never be NULL, but let be paranoiac.
return (*env)->GetStaticDoubleField(env, c, id);
}
}
return 0.0; // Should never happen.
}
/*!
* \brief
* Returns the Proj4 release number.
*
* \param env - The JNI environment.
* \param class - The class from which this method has been invoked.
* \return The Proj4 release number, or NULL.
*/
JNIEXPORT jstring JNICALL Java_org_proj4_PJ_getVersion
(JNIEnv *env, jclass class)
{
const char *desc = pj_get_release();
return (desc) ? (*env)->NewStringUTF(env, desc) : NULL;
}
/*!
* \brief
* Allocates a new PJ structure from a definition string.
*
* \param env - The JNI environment.
* \param class - The class from which this method has been invoked.
* \param definition - The string definition to be given to Proj4.
* \return The address of the new PJ structure, or 0 in case of failure.
*/
JNIEXPORT jlong JNICALL Java_org_proj4_PJ_allocatePJ
(JNIEnv *env, jclass class, jstring definition)
{
const char *def_utf = (*env)->GetStringUTFChars(env, definition, NULL);
if (!def_utf) return 0; /* OutOfMemoryError already thrown. */
PJ *pj = pj_init_plus(def_utf);
(*env)->ReleaseStringUTFChars(env, definition, def_utf);
return (jlong) pj;
}
/*!
* \brief
* Allocates a new geographic PJ structure from an existing one.
*
* \param env - The JNI environment.
* \param class - The class from which this method has been invoked.
* \param projected - The PJ object from which to derive a new one.
* \return The address of the new PJ structure, or 0 in case of failure.
*/
JNIEXPORT jlong JNICALL Java_org_proj4_PJ_allocateGeoPJ
(JNIEnv *env, jclass class, jobject projected)
{
PJ *pj = getPJ(env, projected);
return (pj) ? (jlong) pj_latlong_from_proj(pj) : 0;
}
/*!
* \brief
* Returns the definition string.
*
* \param env - The JNI environment.
* \param object - The Java object wrapping the PJ structure (not allowed to be NULL).
* \return The definition string.
*/
JNIEXPORT jstring JNICALL Java_org_proj4_PJ_getDefinition
(JNIEnv *env, jobject object)
{
PJ *pj = getPJ(env, object);
if (pj) {
char *desc = pj_get_def(pj, 0);
if (desc) {
jstring str = (*env)->NewStringUTF(env, desc);
pj_dalloc(desc);
return str;
}
}
return NULL;
}
/*!
* \brief
* Returns the description associated to the PJ structure.
*
* \param env - The JNI environment.
* \param object - The Java object wrapping the PJ structure (not allowed to be NULL).
* \return The description associated to the PJ structure.
*/
JNIEXPORT jstring JNICALL Java_org_proj4_PJ_toString
(JNIEnv *env, jobject object)
{
PJ *pj = getPJ(env, object);
if (pj) {
const char *desc = pj->descr;
if (desc) {
return (*env)->NewStringUTF(env, desc);
}
}
return NULL;
}
/*!
* \brief
* Returns the CRS type as one of the PJ.Type enum: GEOGRAPHIC, GEOCENTRIC or PROJECTED.
* This function should never return NULL, unless class or fields have been renamed in
* such a way that we can not find anymore the expected enum values.
*
* \param env - The JNI environment.
* \param object - The Java object wrapping the PJ structure (not allowed to be NULL).
* \return The CRS type as one of the PJ.Type enum.
*/
JNIEXPORT jobject JNICALL Java_org_proj4_PJ_getType
(JNIEnv *env, jobject object)
{
PJ *pj = getPJ(env, object);
if (pj) {
const char *type;
if (pj_is_latlong(pj)) {
type = "GEOGRAPHIC";
} else if (pj_is_geocent(pj)) {
type = "GEOCENTRIC";
} else {
type = "PROJECTED";
}
jclass c = (*env)->FindClass(env, "org/proj4/PJ$Type");
if (c) {
jfieldID id = (*env)->GetStaticFieldID(env, c, type, "Lorg/proj4/PJ$Type;");
if (id) {
return (*env)->GetStaticObjectField(env, c, id);
}
}
}
return NULL;
}
/*!
* \brief
* Returns the semi-major axis length.
*
* \param env - The JNI environment.
* \param object - The Java object wrapping the PJ structure (not allowed to be NULL).
* \return The semi-major axis length.
*/
JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getSemiMajorAxis
(JNIEnv *env, jobject object)
{
PJ *pj = getPJ(env, object);
return pj ? pj->a_orig : javaNaN(env);
}
/*!
* \brief
* Computes the semi-minor axis length from the semi-major axis length and the eccentricity
* squared.
*
* \param env - The JNI environment.
* \param object - The Java object wrapping the PJ structure (not allowed to be NULL).
* \return The semi-minor axis length.
*/
JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getSemiMinorAxis
(JNIEnv *env, jobject object)
{
PJ *pj = getPJ(env, object);
if (!pj) return javaNaN(env);
double a = pj->a_orig;
return sqrt(a*a * (1.0 - pj->es_orig));
}
/*!
* \brief
* Returns the eccentricity squared.
*
* \param env - The JNI environment.
* \param object - The Java object wrapping the PJ structure (not allowed to be NULL).
* \return The eccentricity.
*/
JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getEccentricitySquared
(JNIEnv *env, jobject object)
{
PJ *pj = getPJ(env, object);
return pj ? pj->es_orig : javaNaN(env);
}
/*!
* \brief
* Returns an array of character indicating the direction of each axis.
*
* \param env - The JNI environment.
* \param object - The Java object wrapping the PJ structure (not allowed to be NULL).
* \return The axis directions.
*/
JNIEXPORT jcharArray JNICALL Java_org_proj4_PJ_getAxisDirections
(JNIEnv *env, jobject object)
{
PJ *pj = getPJ(env, object);
if (pj) {
int length = strlen(pj->axis);
jcharArray array = (*env)->NewCharArray(env, length);
if (array) {
jchar* axis = (*env)->GetCharArrayElements(env, array, NULL);
if (axis) {
/* Don't use memcp because the type may not be the same. */
int i;
for (i=0; iaxis[i];
}
(*env)->ReleaseCharArrayElements(env, array, axis, 0);
}
return array;
}
}
return NULL;
}
/*!
* \brief
* Longitude of the prime meridian measured from the Greenwich meridian, positive eastward.
*
* \param env - The JNI environment.
* \param object - The Java object wrapping the PJ structure (not allowed to be NULL).
* \return The prime meridian longitude, in degrees.
*/
JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getGreenwichLongitude
(JNIEnv *env, jobject object)
{
PJ *pj = getPJ(env, object);
return (pj) ? (pj->from_greenwich)*(180/M_PI) : javaNaN(env);
}
/*!
* \brief
* Returns the conversion factor from linear units to metres.
*
* \param env - The JNI environment.
* \param object - The Java object wrapping the PJ structure (not allowed to be NULL).
* \param vertical - JNI_FALSE for horizontal axes, or JNI_TRUE for the vertical axis.
* \return The conversion factor to metres.
*/
JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getLinearUnitToMetre
(JNIEnv *env, jobject object, jboolean vertical)
{
PJ *pj = getPJ(env, object);
if (pj) {
return (vertical) ? pj->vto_meter : pj->to_meter;
}
return javaNaN(env);
}
/*!
* \brief
* Converts input values from degrees to radians before coordinate operation, or the output
* values from radians to degrees after the coordinate operation.
*
* \param pj - The Proj.4 PJ structure.
* \param data - The coordinate array to transform.
* \param numPts - Number of points to transform.
* \param dimension - Dimension of points in the coordinate array.
* \param factor - The scale factor to apply: M_PI/180 for inputs or 180/M_PI for outputs.
*/
void convertAngularOrdinates(PJ *pj, double* data, jint numPts, int dimension, double factor) {
int dimToSkip;
if (pj_is_latlong(pj)) {
/* Convert only the 2 first ordinates and skip all the other dimensions. */
dimToSkip = dimension - 2;
} else if (pj_is_geocent(pj)) {
/* Convert only the 3 first ordinates and skip all the other dimensions. */
dimToSkip = dimension - 3;
} else {
/* Not a geographic or geocentric CRS: nothing to convert. */
return;
}
double *stop = data + dimension*numPts;
if (dimToSkip > 0) {
while (data != stop) {
(*data++) *= factor;
(*data++) *= factor;
data += dimToSkip;
}
} else {
while (data != stop) {
(*data++) *= factor;
}
}
}
/*!
* \brief
* Transforms in-place the coordinates in the given array.
*
* \param env - The JNI environment.
* \param object - The Java object wrapping the PJ structure (not allowed to be NULL).
* \param target - The target CRS.
* \param dimension - The dimension of each coordinate value. Must be equals or greater than 2.
* \param coordinates - The coordinates to transform, as a sequence of (x,y,,...) tuples.
* \param offset - Offset of the first coordinate in the given array.
* \param numPts - Number of points to transform.
*/
JNIEXPORT void JNICALL Java_org_proj4_PJ_transform
(JNIEnv *env, jobject object, jobject target, jint dimension, jdoubleArray coordinates, jint offset, jint numPts)
{
if (!target || !coordinates) {
jclass c = (*env)->FindClass(env, "java/lang/NullPointerException");
if (c) (*env)->ThrowNew(env, c, "The target CRS and the coordinates array can not be null.");
return;
}
if (dimension < 2 || dimension > PJ_MAX_DIMENSION) { /* Arbitrary upper value for catching potential misuse. */
jclass c = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
if (c) (*env)->ThrowNew(env, c, "Illegal dimension. Must be in the [2-100] range.");
return;
}
if ((offset < 0) || (numPts < 0) || (offset + dimension*numPts) > (*env)->GetArrayLength(env, coordinates)) {
jclass c = (*env)->FindClass(env, "java/lang/ArrayIndexOutOfBoundsException");
if (c) (*env)->ThrowNew(env, c, "Illegal offset or illegal number of points.");
return;
}
PJ *src_pj = getPJ(env, object);
PJ *dst_pj = getPJ(env, target);
if (src_pj && dst_pj) {
/* Using GetPrimitiveArrayCritical/ReleasePrimitiveArrayCritical rather than
GetDoubleArrayElements/ReleaseDoubleArrayElements increase the chances that
the JVM returns direct reference to its internal array without copying data.
However we must promise to run the "critical" code fast, to not make any
system call that may wait for the JVM and to not invoke any other JNI method. */
double *data = (*env)->GetPrimitiveArrayCritical(env, coordinates, NULL);
if (data) {
double *x = data + offset;
double *y = x + 1;
double *z = (dimension >= 3) ? y+1 : NULL;
convertAngularOrdinates(src_pj, x, numPts, dimension, M_PI/180);
int err = pj_transform(src_pj, dst_pj, numPts, dimension, x, y, z);
convertAngularOrdinates(dst_pj, x, numPts, dimension, 180/M_PI);
(*env)->ReleasePrimitiveArrayCritical(env, coordinates, data, 0);
if (err) {
jclass c = (*env)->FindClass(env, "org/proj4/PJException");
if (c) (*env)->ThrowNew(env, c, pj_strerrno(err));
}
}
}
}
/*!
* \brief
* Returns a description of the last error that occurred, or NULL if none.
*
* \param env - The JNI environment.
* \param object - The Java object wrapping the PJ structure (not allowed to be NULL).
* \return The last error, or NULL.
*/
JNIEXPORT jstring JNICALL Java_org_proj4_PJ_getLastError
(JNIEnv *env, jobject object)
{
PJ *pj = getPJ(env, object);
if (pj) {
int err = pj_ctx_get_errno(pj->ctx);
if (err) {
return (*env)->NewStringUTF(env, pj_strerrno(err));
}
}
return NULL;
}
/*!
* \brief
* Deallocate the PJ structure. This method is invoked by the garbage collector exactly once.
* This method will also set the Java "ptr" final field to 0 as a safety. In theory we are not
* supposed to change the value of a final field. But no Java code should use this field, and
* the PJ object is being garbage collected anyway. We set the field to 0 as a safety in case
* some user invoked the finalize() method explicitely despite our warning in the Javadoc to
* never do such thing.
*
* \param env - The JNI environment.
* \param object - The Java object wrapping the PJ structure (not allowed to be NULL).
*/
JNIEXPORT void JNICALL Java_org_proj4_PJ_finalize
(JNIEnv *env, jobject object)
{
jfieldID id = (*env)->GetFieldID(env, (*env)->GetObjectClass(env, object), PJ_FIELD_NAME, PJ_FIELD_TYPE);
if (id) {
PJ *pj = (PJ*) (*env)->GetLongField(env, object, id);
if (pj) {
(*env)->SetLongField(env, object, id, (jlong) 0);
pj_free(pj);
}
}
}
#endif
proj-4.9.3/src/pj_phi2.c 0000644 0000000 0000000 00000000744 12761101536 011665 0000000 0000000 /* determine latitude angle phi-2 */
#include
#define TOL 1.0e-10
#define N_ITER 15
double
pj_phi2(projCtx ctx, double ts, double e) {
double eccnth, Phi, con, dphi;
int i;
eccnth = .5 * e;
Phi = M_HALFPI - 2. * atan (ts);
i = N_ITER;
do {
con = e * sin (Phi);
dphi = M_HALFPI - 2. * atan (ts * pow((1. - con) /
(1. + con), eccnth)) - Phi;
Phi += dphi;
} while ( fabs(dphi) > TOL && --i);
if (i <= 0)
pj_ctx_set_errno( ctx, -18 );
return Phi;
}
proj-4.9.3/src/bchgen.c 0000644 0000000 0000000 00000002555 12761101536 011562 0000000 0000000 /* generate double bivariate Chebychev polynomial */
#include
int
bchgen(projUV a, projUV b, int nu, int nv, projUV **f, projUV(*func)(projUV)) {
int i, j, k;
projUV arg, *t, bma, bpa, *c;
double d, fac;
bma.u = 0.5 * (b.u - a.u); bma.v = 0.5 * (b.v - a.v);
bpa.u = 0.5 * (b.u + a.u); bpa.v = 0.5 * (b.v + a.v);
for ( i = 0; i < nu; ++i) {
arg.u = cos(M_PI * (i + 0.5) / nu) * bma.u + bpa.u;
for ( j = 0; j < nv; ++j) {
arg.v = cos(M_PI * (j + 0.5) / nv) * bma.v + bpa.v;
f[i][j] = (*func)(arg);
if ((f[i][j]).u == HUGE_VAL)
return(1);
}
}
if (!(c = (projUV *) vector1(nu, sizeof(projUV)))) return 1;
fac = 2. / nu;
for ( j = 0; j < nv ; ++j) {
for ( i = 0; i < nu; ++i) {
arg.u = arg.v = 0.;
for (k = 0; k < nu; ++k) {
d = cos(M_PI * i * (k + .5) / nu);
arg.u += f[k][j].u * d;
arg.v += f[k][j].v * d;
}
arg.u *= fac;
arg.v *= fac;
c[i] = arg;
}
for (i = 0; i < nu; ++i)
f[i][j] = c[i];
}
pj_dalloc(c);
if (!(c = (projUV*) vector1(nv, sizeof(projUV)))) return 1;
fac = 2. / nv;
for ( i = 0; i < nu; ++i) {
t = f[i];
for (j = 0; j < nv; ++j) {
arg.u = arg.v = 0.;
for (k = 0; k < nv; ++k) {
d = cos(M_PI * j * (k + .5) / nv);
arg.u += t[k].u * d;
arg.v += t[k].v * d;
}
arg.u *= fac;
arg.v *= fac;
c[j] = arg;
}
f[i] = c;
c = t;
}
pj_dalloc(c);
return(0);
}
proj-4.9.3/src/pj_fwd.c 0000644 0000000 0000000 00000002370 12761101536 011600 0000000 0000000 /* general forward projection */
#define PJ_LIB__
#include
#include
# define EPS 1.0e-12
XY /* forward projection entry */
pj_fwd(LP lp, PJ *P) {
XY xy;
double t;
/* check for forward and latitude or longitude overange */
if ((t = fabs(lp.phi)-M_HALFPI) > EPS || fabs(lp.lam) > 10.) {
xy.x = xy.y = HUGE_VAL;
pj_ctx_set_errno( P->ctx, -14);
} else { /* proceed with projection */
P->ctx->last_errno = 0;
pj_errno = 0;
errno = 0;
if (fabs(t) <= EPS)
lp.phi = lp.phi < 0. ? -M_HALFPI : M_HALFPI;
else if (P->geoc)
lp.phi = atan(P->rone_es * tan(lp.phi));
lp.lam -= P->lam0; /* compute del lp.lam */
if (!P->over)
lp.lam = adjlon(lp.lam); /* adjust del longitude */
/* Check for NULL pointer */
if (P->fwd != NULL)
{
xy = (*P->fwd)(lp, P); /* project */
if ( P->ctx->last_errno )
xy.x = xy.y = HUGE_VAL;
/* adjust for major axis and easting/northings */
else {
xy.x = P->fr_meter * (P->a * xy.x + P->x0);
xy.y = P->fr_meter * (P->a * xy.y + P->y0);
}
}
else
{
xy.x = xy.y = HUGE_VAL;
}
}
return xy;
}
proj-4.9.3/src/pj_run_selftests.c 0000644 0000000 0000000 00000005540 12761101536 013722 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Generic regression test for PROJ.4 projection algorithms.
* Author: Thomas Knudsen
*
******************************************************************************
* Copyright (c) 2016, Thomas Knudsen
*
* 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.
*****************************************************************************/
#include
#define PJ_LIB__
#include
static void run_one_test (const char *mnemonic, int (testfunc)(void), int verbosity, int *n_ok, int *n_ko, int *n_stubs) {
int ret = testfunc ();
switch (ret) {
case 0: (*n_ok)++; break;
case 10000: (*n_stubs)++; break;
default: (*n_ko)++;
}
if (verbosity) {
if (ret==10000)
printf ("Testing: %10s - [stub]\n", mnemonic);
else
printf ("Testing: %10s - return code: %d\n", mnemonic, ret);
}
return;
}
#ifndef PJ_SELFTEST
int pj_run_selftests (int verbosity) {
printf ("This version of libproj is not configured for internal regression tests.\n");
return 0;
}
#else
int pj_run_selftests (int verbosity) {
int n_ok = 0, n_ko = 0, n_stubs = 0, i = 0;
struct PJ_SELFTEST_LIST *tests = pj_get_selftest_list_ref ();
if (0==tests)
printf ("This version of libproj is not configured for internal regression tests.\n");
if (verbosity)
printf ("Running internal regression tests\n");
for (i = 0; tests[i].testfunc != 0; i++)
run_one_test (tests[i].id, tests[i].testfunc, verbosity, &n_ok, &n_ko, &n_stubs);
if (0==verbosity)
printf ("Internal regression tests done. ");
printf ("[Stubs: %d] Total: %d. Failure: %d. Success: %d\n", n_stubs, n_ok+n_ko, n_ko, n_ok);
return n_ko;
}
#endif
proj-4.9.3/src/PJ_tcc.c 0000644 0000000 0000000 00000002560 12761101536 011472 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(tcc, "Transverse Central Cylindrical") "\n\tCyl, Sph, no inv.";
#define EPS10 1.e-10
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0, 0.0};
double b, bt;
b = cos (lp.phi) * sin (lp.lam);
if ((bt = 1. - b * b) < EPS10) F_ERROR;
xy.x = b / sqrt(bt);
xy.y = atan2 (tan (lp.phi) , cos (lp.lam));
return xy;
}
static void *freeup_new (PJ *P) { /* Destructor */
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(tcc) {
P->es = 0.;
P->fwd = s_forward;
P->inv = 0;
return P;
}
#ifndef PJ_SELFTEST
int pj_tcc_selftest (void) {return 0;}
#else
int pj_tcc_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=tcc +a=6400000 +lat_1=0.5 +lat_2=2 +n=0.5"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{223458.84419245756, 111769.14504058579},
{223458.84419245756, -111769.14504058579},
{-223458.84419245756, 111769.14504058579},
{-223458.84419245756, -111769.14504058579},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/pj_list.h 0000644 0000000 0000000 00000013407 12761101536 012003 0000000 0000000 #ifdef DO_PJ_LIST_ID
static const char PJ_LIST_H_ID[] = "@(#)pj_list.h 4.5 95/08/09 GIE REL";
#endif
/* Full list of current projections for Tue Jan 11 12:27:04 EST 1994
**
** Copy this file and retain only appropriate lines for subset list
*/
PROJ_HEAD(aea, "Albers Equal Area")
PROJ_HEAD(aeqd, "Azimuthal Equidistant")
PROJ_HEAD(airy, "Airy")
PROJ_HEAD(aitoff, "Aitoff")
PROJ_HEAD(alsk, "Mod. Stererographics of Alaska")
PROJ_HEAD(apian, "Apian Globular I")
PROJ_HEAD(august, "August Epicycloidal")
PROJ_HEAD(bacon, "Bacon Globular")
PROJ_HEAD(bipc, "Bipolar conic of western hemisphere")
PROJ_HEAD(boggs, "Boggs Eumorphic")
PROJ_HEAD(bonne, "Bonne (Werner lat_1=90)")
PROJ_HEAD(calcofi, "Cal Coop Ocean Fish Invest Lines/Stations")
PROJ_HEAD(cass, "Cassini")
PROJ_HEAD(cc, "Central Cylindrical")
PROJ_HEAD(cea, "Equal Area Cylindrical")
PROJ_HEAD(chamb, "Chamberlin Trimetric")
PROJ_HEAD(collg, "Collignon")
PROJ_HEAD(comill, "Compact Miller")
PROJ_HEAD(crast, "Craster Parabolic (Putnins P4)")
PROJ_HEAD(denoy, "Denoyer Semi-Elliptical")
PROJ_HEAD(eck1, "Eckert I")
PROJ_HEAD(eck2, "Eckert II")
PROJ_HEAD(eck3, "Eckert III")
PROJ_HEAD(eck4, "Eckert IV")
PROJ_HEAD(eck5, "Eckert V")
PROJ_HEAD(eck6, "Eckert VI")
PROJ_HEAD(eqc, "Equidistant Cylindrical (Plate Caree)")
PROJ_HEAD(eqdc, "Equidistant Conic")
PROJ_HEAD(euler, "Euler")
PROJ_HEAD(etmerc, "Extended Transverse Mercator" )
PROJ_HEAD(fahey, "Fahey")
PROJ_HEAD(fouc, "Foucaut")
PROJ_HEAD(fouc_s, "Foucaut Sinusoidal")
PROJ_HEAD(gall, "Gall (Gall Stereographic)")
PROJ_HEAD(geocent, "Geocentric")
PROJ_HEAD(geos, "Geostationary Satellite View")
PROJ_HEAD(gins8, "Ginsburg VIII (TsNIIGAiK)")
PROJ_HEAD(gn_sinu, "General Sinusoidal Series")
PROJ_HEAD(gnom, "Gnomonic")
PROJ_HEAD(goode, "Goode Homolosine")
PROJ_HEAD(gs48, "Mod. Stererographics of 48 U.S.")
PROJ_HEAD(gs50, "Mod. Stererographics of 50 U.S.")
PROJ_HEAD(hammer, "Hammer & Eckert-Greifendorff")
PROJ_HEAD(hatano, "Hatano Asymmetrical Equal Area")
PROJ_HEAD(healpix, "HEALPix")
PROJ_HEAD(rhealpix, "rHEALPix")
PROJ_HEAD(igh, "Interrupted Goode Homolosine")
PROJ_HEAD(imw_p, "Internation Map of the World Polyconic")
PROJ_HEAD(isea, "Icosahedral Snyder Equal Area")
PROJ_HEAD(kav5, "Kavraisky V")
PROJ_HEAD(kav7, "Kavraisky VII")
PROJ_HEAD(krovak, "Krovak")
PROJ_HEAD(labrd, "Laborde")
PROJ_HEAD(laea, "Lambert Azimuthal Equal Area")
PROJ_HEAD(lagrng, "Lagrange")
PROJ_HEAD(larr, "Larrivee")
PROJ_HEAD(lask, "Laskowski")
PROJ_HEAD(lonlat, "Lat/long (Geodetic)")
PROJ_HEAD(latlon, "Lat/long (Geodetic alias)")
PROJ_HEAD(latlong, "Lat/long (Geodetic alias)")
PROJ_HEAD(longlat, "Lat/long (Geodetic alias)")
PROJ_HEAD(lcc, "Lambert Conformal Conic")
PROJ_HEAD(lcca, "Lambert Conformal Conic Alternative")
PROJ_HEAD(leac, "Lambert Equal Area Conic")
PROJ_HEAD(lee_os, "Lee Oblated Stereographic")
PROJ_HEAD(loxim, "Loximuthal")
PROJ_HEAD(lsat, "Space oblique for LANDSAT")
PROJ_HEAD(mbt_s, "McBryde-Thomas Flat-Polar Sine")
PROJ_HEAD(mbt_fps, "McBryde-Thomas Flat-Pole Sine (No. 2)")
PROJ_HEAD(mbtfpp, "McBride-Thomas Flat-Polar Parabolic")
PROJ_HEAD(mbtfpq, "McBryde-Thomas Flat-Polar Quartic")
PROJ_HEAD(mbtfps, "McBryde-Thomas Flat-Polar Sinusoidal")
PROJ_HEAD(merc, "Mercator")
PROJ_HEAD(mil_os, "Miller Oblated Stereographic")
PROJ_HEAD(mill, "Miller Cylindrical")
PROJ_HEAD(misrsom, "Space oblique for MISR")
PROJ_HEAD(moll, "Mollweide")
PROJ_HEAD(murd1, "Murdoch I")
PROJ_HEAD(murd2, "Murdoch II")
PROJ_HEAD(murd3, "Murdoch III")
PROJ_HEAD(natearth, "Natural Earth")
PROJ_HEAD(natearth2, "Natural Earth II")
PROJ_HEAD(nell, "Nell")
PROJ_HEAD(nell_h, "Nell-Hammer")
PROJ_HEAD(nicol, "Nicolosi Globular")
PROJ_HEAD(nsper, "Near-sided perspective")
PROJ_HEAD(nzmg, "New Zealand Map Grid")
PROJ_HEAD(ob_tran, "General Oblique Transformation")
PROJ_HEAD(ocea, "Oblique Cylindrical Equal Area")
PROJ_HEAD(oea, "Oblated Equal Area")
PROJ_HEAD(omerc, "Oblique Mercator")
PROJ_HEAD(ortel, "Ortelius Oval")
PROJ_HEAD(ortho, "Orthographic")
PROJ_HEAD(pconic, "Perspective Conic")
PROJ_HEAD(patterson, "Patterson Cylindrical")
PROJ_HEAD(poly, "Polyconic (American)")
PROJ_HEAD(putp1, "Putnins P1")
PROJ_HEAD(putp2, "Putnins P2")
PROJ_HEAD(putp3, "Putnins P3")
PROJ_HEAD(putp3p, "Putnins P3'")
PROJ_HEAD(putp4p, "Putnins P4'")
PROJ_HEAD(putp5, "Putnins P5")
PROJ_HEAD(putp5p, "Putnins P5'")
PROJ_HEAD(putp6, "Putnins P6")
PROJ_HEAD(putp6p, "Putnins P6'")
PROJ_HEAD(qua_aut, "Quartic Authalic")
PROJ_HEAD(qsc, "Quadrilateralized Spherical Cube")
PROJ_HEAD(robin, "Robinson")
PROJ_HEAD(rouss, "Roussilhe Stereographic")
PROJ_HEAD(rpoly, "Rectangular Polyconic")
PROJ_HEAD(sch, "Spherical Cross-track Height")
PROJ_HEAD(sinu, "Sinusoidal (Sanson-Flamsteed)")
PROJ_HEAD(somerc, "Swiss. Obl. Mercator")
PROJ_HEAD(stere, "Stereographic")
PROJ_HEAD(sterea, "Oblique Stereographic Alternative")
PROJ_HEAD(gstmerc, "Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion)")
PROJ_HEAD(tcc, "Transverse Central Cylindrical")
PROJ_HEAD(tcea, "Transverse Cylindrical Equal Area")
PROJ_HEAD(times, "Times Projection")
PROJ_HEAD(tissot, "Tissot Conic")
PROJ_HEAD(tmerc, "Transverse Mercator")
PROJ_HEAD(tpeqd, "Two Point Equidistant")
PROJ_HEAD(tpers, "Tilted perspective")
PROJ_HEAD(ups, "Universal Polar Stereographic")
PROJ_HEAD(urm5, "Urmaev V")
PROJ_HEAD(urmfps, "Urmaev Flat-Polar Sinusoidal")
PROJ_HEAD(utm, "Universal Transverse Mercator (UTM)")
PROJ_HEAD(vandg, "van der Grinten (I)")
PROJ_HEAD(vandg2, "van der Grinten II")
PROJ_HEAD(vandg3, "van der Grinten III")
PROJ_HEAD(vandg4, "van der Grinten IV")
PROJ_HEAD(vitk1, "Vitkovsky I")
PROJ_HEAD(wag1, "Wagner I (Kavraisky VI)")
PROJ_HEAD(wag2, "Wagner II")
PROJ_HEAD(wag3, "Wagner III")
PROJ_HEAD(wag4, "Wagner IV")
PROJ_HEAD(wag5, "Wagner V")
PROJ_HEAD(wag6, "Wagner VI")
PROJ_HEAD(wag7, "Wagner VII")
PROJ_HEAD(weren, "Werenskiold I")
PROJ_HEAD(wink1, "Winkel I")
PROJ_HEAD(wink2, "Winkel II")
PROJ_HEAD(wintri, "Winkel Tripel")
proj-4.9.3/src/vector1.c 0000644 0000000 0000000 00000001245 12761101536 011712 0000000 0000000 /* make storage for one and two dimensional matricies */
#include
#include
void * /* one dimension array */
vector1(int nvals, int size) { return((void *)pj_malloc(size * nvals)); }
void /* free 2D array */
freev2(void **v, int nrows) {
if (v) {
for (v += nrows; nrows > 0; --nrows)
pj_dalloc(*--v);
pj_dalloc(v);
}
}
void ** /* two dimension array */
vector2(int nrows, int ncols, int size) {
void **s;
if ((s = (void **)pj_malloc(sizeof(void *) * nrows)) != NULL) {
int rsize, i;
rsize = size * ncols;
for (i = 0; i < nrows; ++i)
if (!(s[i] = pj_malloc(rsize))) {
freev2(s, i);
return (void **)0;
}
}
return s;
}
proj-4.9.3/src/pj_malloc.c 0000644 0000000 0000000 00000004042 12761101536 012265 0000000 0000000 /* allocate and deallocate memory */
/* These routines are used so that applications can readily replace
** projection system memory allocation/deallocation call with custom
** application procedures. */
#include
#include
void *
pj_malloc(size_t size) {
/*
/ Currently, pj_malloc is a hack to solve an errno problem.
/ The problem is described in more details at
/ https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=86420.
/ It seems, that pj_init and similar functions incorrectly
/ (under debian/glibs-2.3.2) assume that pj_malloc resets
/ errno after success. pj_malloc tries to mimic this.
*/
int old_errno = errno;
void *res = malloc(size);
if ( res && !old_errno )
errno = 0;
return res;
}
void
pj_dalloc(void *ptr) {
free(ptr);
}
/**********************************************************************/
void *pj_calloc (size_t n, size_t size) {
/***********************************************************************
pj_calloc is the pj-equivalent of calloc().
It allocates space for an array of elements of size .
The array is initialized to zeros.
***********************************************************************/
void *res = pj_malloc (n*size);
if (0==res)
return 0;
memset (res, 0, n*size);
return res;
}
/**********************************************************************/
void *pj_dealloc (void *ptr) {
/***********************************************************************
pj_dealloc supports the common use case of "clean up and return a null
pointer" to signal an error in a multi level allocation:
struct foo { int bar; int *baz; };
struct foo *p = pj_calloc (1, sizeof (struct foo));
if (0==p)
return 0;
p->baz = pj_calloc (10, sizeof(int));
if (0==p->baz)
return pj_dealloc (p); // clean up + signal error by 0-return
return p; // success
***********************************************************************/
if (0==ptr)
return 0;
pj_dalloc (ptr);
return 0;
}
proj-4.9.3/src/pj_ctx.c 0000644 0000000 0000000 00000015111 12761101536 011613 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Implementation of the projCtx thread context object.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2010, 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.
*****************************************************************************/
#include
#include
static projCtx_t default_context;
static volatile int default_context_initialized = 0;
/************************************************************************/
/* pj_get_ctx() */
/************************************************************************/
projCtx pj_get_ctx( projPJ pj )
{
return pj->ctx;
}
/************************************************************************/
/* pj_set_ctx() */
/* */
/* Note we do not deallocate the old context! */
/************************************************************************/
void pj_set_ctx( projPJ pj, projCtx ctx )
{
pj->ctx = ctx;
}
/************************************************************************/
/* pj_get_default_ctx() */
/************************************************************************/
projCtx pj_get_default_ctx()
{
pj_acquire_lock();
if( !default_context_initialized )
{
default_context.last_errno = 0;
default_context.debug_level = PJ_LOG_NONE;
default_context.logger = pj_stderr_logger;
default_context.app_data = NULL;
default_context.fileapi = pj_get_default_fileapi();
if( getenv("PROJ_DEBUG") != NULL )
{
if( atoi(getenv("PROJ_DEBUG")) > 0 )
default_context.debug_level = atoi(getenv("PROJ_DEBUG"));
else
default_context.debug_level = PJ_LOG_DEBUG_MINOR;
}
default_context_initialized = 1;
}
pj_release_lock();
return &default_context;
}
/************************************************************************/
/* pj_ctx_alloc() */
/************************************************************************/
projCtx pj_ctx_alloc()
{
projCtx ctx = (projCtx_t *) malloc(sizeof(projCtx_t));
memcpy( ctx, pj_get_default_ctx(), sizeof(projCtx_t) );
ctx->last_errno = 0;
return ctx;
}
/************************************************************************/
/* pj_ctx_free() */
/************************************************************************/
void pj_ctx_free( projCtx ctx )
{
free( ctx );
}
/************************************************************************/
/* pj_ctx_get_errno() */
/************************************************************************/
int pj_ctx_get_errno( projCtx ctx )
{
return ctx->last_errno;
}
/************************************************************************/
/* pj_ctx_set_errno() */
/* */
/* Also sets the global errno. */
/************************************************************************/
void pj_ctx_set_errno( projCtx ctx, int new_errno )
{
ctx->last_errno = new_errno;
if( new_errno != 0 )
pj_errno = new_errno;
}
/************************************************************************/
/* pj_ctx_set_debug() */
/************************************************************************/
void pj_ctx_set_debug( projCtx ctx, int new_debug )
{
ctx->debug_level = new_debug;
}
/************************************************************************/
/* pj_ctx_set_logger() */
/************************************************************************/
void pj_ctx_set_logger( projCtx ctx, void (*new_logger)(void*,int,const char*) )
{
ctx->logger = new_logger;
}
/************************************************************************/
/* pj_ctx_set_app_data() */
/************************************************************************/
void pj_ctx_set_app_data( projCtx ctx, void *new_app_data )
{
ctx->app_data = new_app_data;
}
/************************************************************************/
/* pj_ctx_get_app_data() */
/************************************************************************/
void *pj_ctx_get_app_data( projCtx ctx )
{
return ctx->app_data;
}
/************************************************************************/
/* pj_ctx_set_fileapi() */
/************************************************************************/
void pj_ctx_set_fileapi( projCtx ctx, projFileAPI *fileapi )
{
ctx->fileapi = fileapi;
}
/************************************************************************/
/* pj_ctx_get_fileapi() */
/************************************************************************/
projFileAPI *pj_ctx_get_fileapi( projCtx ctx )
{
return ctx->fileapi;
}
proj-4.9.3/src/PJ_patterson.c 0000644 0000000 0000000 00000010261 12761101536 012735 0000000 0000000 /*
* Copyright (c) 2014 Bojan Savric
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* The Patterson Cylindrical projection was designed by Tom Patterson, US National
* Park Service, in 2014, using Flex Projector. The polynomial equations for the
* projection were developed by Bojan Savric, Oregon State University, in
* collaboration with Tom Patterson and Bernhard Jenny, Oregon State University.
*
* Java reference algorithm implemented by Bojan Savric in Java Map Projection
* Library (a Java port of PROJ.4) in the file PattersonProjection.java.
*
* References:
* Java Map Projection Library
* https://github.com/OSUCartography/JMapProjLib
*
* Patterson Cylindrical Projection
* http://shadedrelief.com/patterson/
*
* Patterson, T., Savric, B., and Jenny, B. (2015). Cartographic Perspectives
* (No.78). Describes the projection design and characteristics, and
* developing the equations. doi:10.14714/CP78.1270
* http://dx.doi.org/10.14714/CP78.1270
*
* Port to PROJ.4 by Micah Cochran, 26 March 2016
*/
#define PJ_LIB__
#include
PROJ_HEAD(patterson, "Patterson Cylindrical") "\n\tCyl.";
#define K1 1.0148
#define K2 0.23185
#define K3 -0.14499
#define K4 0.02406
#define C1 K1
#define C2 (5.0 * K2)
#define C3 (7.0 * K3)
#define C4 (9.0 * K4)
#define EPS11 1.0e-11
#define MAX_Y 1.790857183
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
double phi2;
(void) P;
phi2 = lp.phi * lp.phi;
xy.x = lp.lam;
xy.y = lp.phi * (K1 + phi2 * phi2 * (K2 + phi2 * (K3 + K4 * phi2)));
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
double yc, tol, y2, f, fder;
(void) P;
yc = xy.y;
/* make sure y is inside valid range */
if (xy.y > MAX_Y) {
xy.y = MAX_Y;
} else if (xy.y < -MAX_Y) {
xy.y = -MAX_Y;
}
for (;;) { /* Newton-Raphson */
y2 = yc * yc;
f = (yc * (K1 + y2 * y2 * (K2 + y2 * (K3 + K4 * y2)))) - xy.y;
fder = C1 + y2 * y2 * (C2 + y2 * (C3 + C4 * y2));
yc -= tol = f / fder;
if (fabs(tol) < EPS11) {
break;
}
}
lp.phi = yc;
/* longitude */
lp.lam = xy.x;
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(patterson) {
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_patterson_selftest (void) {return 0;}
#else
int pj_patterson_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=patterson +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{223402.144255274179, 113354.250397779804},
{223402.144255274179, -113354.250397779804},
{-223402.144255274179, 113354.250397779804},
{-223402.144255274179, -113354.250397779804},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{0.00179049310978382265, 0.000882190140807953657},
{0.00179049310978382265, -0.000882190140807953657},
{-0.00179049310978382265, 0.000882190140807953657},
{-0.00179049310978382265, -0.000882190140807953657},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/proj_api.h 0000644 0000000 0000000 00000015073 12761101536 012143 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Public (application) include file for PROJ.4 API, and constants.
* Author: Frank Warmerdam,
*
******************************************************************************
* Copyright (c) 2001, 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 PROJ_API_H
#define PROJ_API_H
/* standard inclusions */
#include
#include
#ifdef __cplusplus
extern "C" {
#endif
/*
* This version number should be updated with every release! The format of
* PJ_VERSION is
*
* * Before version 4.10.0: PJ_VERSION=MNP where M, N, and P are the major,
* minor, and patch numbers; e.g., PJ_VERSION=493 for version 4.9.3.
*
* * Version 4.10.0 and later: PJ_VERSION=MMMNNNPP later where MMM, NNN, PP
* are the major, minor, and patch numbers (the minor and patch numbers
* are padded with leading zeros if necessary); e.g., PJ_VERSION=401000
* for version 4.10.0.
*/
#define PJ_VERSION 493
/* pj_init() and similar functions can be used with a non-C locale */
/* Can be detected too at runtime if the symbol pj_atof exists */
#define PJ_LOCALE_SAFE 1
extern char const pj_release[]; /* global release id string */
#define RAD_TO_DEG 57.295779513082321
#define DEG_TO_RAD .017453292519943296
extern int pj_errno; /* global error return code */
#if !defined(PROJECTS_H)
typedef struct { double u, v; } projUV;
typedef struct { double u, v, w; } projUVW;
typedef void *projPJ;
#define projXY projUV
#define projLP projUV
#define projXYZ projUVW
#define projLPZ projUVW
typedef void *projCtx;
#else
typedef PJ *projPJ;
typedef projCtx_t *projCtx;
# define projXY XY
# define projLP LP
# define projXYZ XYZ
# define projLPZ LPZ
#endif
/* file reading api, like stdio */
typedef int *PAFile;
typedef struct projFileAPI_t {
PAFile (*FOpen)(projCtx ctx, const char *filename, const char *access);
size_t (*FRead)(void *buffer, size_t size, size_t nmemb, PAFile file);
int (*FSeek)(PAFile file, long offset, int whence);
long (*FTell)(PAFile file);
void (*FClose)(PAFile);
} projFileAPI;
/* procedure prototypes */
projXY pj_fwd(projLP, projPJ);
projLP pj_inv(projXY, projPJ);
projXYZ pj_fwd3d(projLPZ, projPJ);
projLPZ pj_inv3d(projXYZ, projPJ);
int pj_transform( projPJ src, projPJ dst, long point_count, int point_offset,
double *x, double *y, double *z );
int pj_datum_transform( projPJ src, projPJ dst, long point_count, int point_offset,
double *x, double *y, double *z );
int pj_geocentric_to_geodetic( double a, double es,
long point_count, int point_offset,
double *x, double *y, double *z );
int pj_geodetic_to_geocentric( double a, double es,
long point_count, int point_offset,
double *x, double *y, double *z );
int pj_compare_datums( projPJ srcdefn, projPJ dstdefn );
int pj_apply_gridshift( projCtx, const char *, int,
long point_count, int point_offset,
double *x, double *y, double *z );
void pj_deallocate_grids(void);
void pj_clear_initcache(void);
int pj_is_latlong(projPJ);
int pj_is_geocent(projPJ);
void pj_get_spheroid_defn(projPJ defn, double *major_axis, double *eccentricity_squared);
void pj_pr_list(projPJ);
void pj_free(projPJ);
void pj_set_finder( const char *(*)(const char *) );
void pj_set_searchpath ( int count, const char **path );
projPJ pj_init(int, char **);
projPJ pj_init_plus(const char *);
projPJ pj_init_ctx( projCtx, int, char ** );
projPJ pj_init_plus_ctx( projCtx, const char * );
char *pj_get_def(projPJ, int);
projPJ pj_latlong_from_proj( projPJ );
void *pj_malloc(size_t);
void pj_dalloc(void *);
void *pj_calloc (size_t n, size_t size);
void *pj_dealloc (void *ptr);
char *pj_strerrno(int);
int *pj_get_errno_ref(void);
const char *pj_get_release(void);
void pj_acquire_lock(void);
void pj_release_lock(void);
void pj_cleanup_lock(void);
projCtx pj_get_default_ctx(void);
projCtx pj_get_ctx( projPJ );
void pj_set_ctx( projPJ, projCtx );
projCtx pj_ctx_alloc(void);
void pj_ctx_free( projCtx );
int pj_ctx_get_errno( projCtx );
void pj_ctx_set_errno( projCtx, int );
void pj_ctx_set_debug( projCtx, int );
void pj_ctx_set_logger( projCtx, void (*)(void *, int, const char *) );
void pj_ctx_set_app_data( projCtx, void * );
void *pj_ctx_get_app_data( projCtx );
void pj_ctx_set_fileapi( projCtx, projFileAPI *);
projFileAPI *pj_ctx_get_fileapi( projCtx );
void pj_log( projCtx ctx, int level, const char *fmt, ... );
void pj_stderr_logger( void *, int, const char * );
/* file api */
projFileAPI *pj_get_default_fileapi();
PAFile pj_ctx_fopen(projCtx ctx, const char *filename, const char *access);
size_t pj_ctx_fread(projCtx ctx, void *buffer, size_t size, size_t nmemb, PAFile file);
int pj_ctx_fseek(projCtx ctx, PAFile file, long offset, int whence);
long pj_ctx_ftell(projCtx ctx, PAFile file);
void pj_ctx_fclose(projCtx ctx, PAFile file);
char *pj_ctx_fgets(projCtx ctx, char *line, int size, PAFile file);
PAFile pj_open_lib(projCtx, const char *, const char *);
int pj_run_selftests (int verbosity);
#define PJ_LOG_NONE 0
#define PJ_LOG_ERROR 1
#define PJ_LOG_DEBUG_MAJOR 2
#define PJ_LOG_DEBUG_MINOR 3
#ifdef __cplusplus
}
#endif
#endif /* ndef PROJ_API_H */
proj-4.9.3/src/PJ_lsat.c 0000644 0000000 0000000 00000016561 12761101536 011672 0000000 0000000 /* based upon Snyder and Linck, USGS-NMD */
#define PJ_LIB__
#include
PROJ_HEAD(lsat, "Space oblique for LANDSAT")
"\n\tCyl, Sph&Ell\n\tlsat= path=";
#define TOL 1e-7
struct pj_opaque {
double a2, a4, b, c1, c3;
double q, t, u, w, p22, sa, ca, xj, rlm, rlm2;
};
static void seraz0(double lam, double mult, PJ *P) {
struct pj_opaque *Q = P->opaque;
double sdsq, h, s, fc, sd, sq, d__1 = 0;
lam *= DEG_TO_RAD;
sd = sin(lam);
sdsq = sd * sd;
s = Q->p22 * Q->sa * cos(lam) * sqrt((1. + Q->t * sdsq)
/ ((1. + Q->w * sdsq) * (1. + Q->q * sdsq)));
h = sqrt((1. + Q->q * sdsq) / (1. + Q->w * sdsq)) * ((1. + Q->w * sdsq)
/ (d__1 * d__1) - Q->p22 * Q->ca);
sq = sqrt(Q->xj * Q->xj + s * s);
fc = mult * (h * Q->xj - s * s) / sq;
Q->b += fc;
Q->a2 += fc * cos(lam + lam);
Q->a4 += fc * cos(lam * 4.);
fc = mult * s * (h + Q->xj) / sq;
Q->c1 += fc * cos(lam);
Q->c3 += fc * cos(lam * 3.);
}
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
int l, nn;
double lamt, xlam, sdsq, c, d, s, lamdp, phidp, lampp, tanph;
double lamtp, cl, sd, sp, fac, sav, tanphi;
if (lp.phi > M_HALFPI)
lp.phi = M_HALFPI;
else if (lp.phi < -M_HALFPI)
lp.phi = -M_HALFPI;
lampp = lp.phi >= 0. ? M_HALFPI : M_PI_HALFPI;
tanphi = tan(lp.phi);
for (nn = 0;;) {
sav = lampp;
lamtp = lp.lam + Q->p22 * lampp;
cl = cos(lamtp);
if (fabs(cl) < TOL)
lamtp -= TOL;
fac = lampp - sin(lampp) * (cl < 0. ? -M_HALFPI : M_HALFPI);
for (l = 50; l; --l) {
lamt = lp.lam + Q->p22 * sav;
c = cos(lamt);
if (fabs(c) < TOL)
lamt -= TOL;
xlam = (P->one_es * tanphi * Q->sa + sin(lamt) * Q->ca) / c;
lamdp = atan(xlam) + fac;
if (fabs(fabs(sav) - fabs(lamdp)) < TOL)
break;
sav = lamdp;
}
if (!l || ++nn >= 3 || (lamdp > Q->rlm && lamdp < Q->rlm2))
break;
if (lamdp <= Q->rlm)
lampp = M_TWOPI_HALFPI;
else if (lamdp >= Q->rlm2)
lampp = M_HALFPI;
}
if (l) {
sp = sin(lp.phi);
phidp = aasin(P->ctx,(P->one_es * Q->ca * sp - Q->sa * cos(lp.phi) *
sin(lamt)) / sqrt(1. - P->es * sp * sp));
tanph = log(tan(M_FORTPI + .5 * phidp));
sd = sin(lamdp);
sdsq = sd * sd;
s = Q->p22 * Q->sa * cos(lamdp) * sqrt((1. + Q->t * sdsq)
/ ((1. + Q->w * sdsq) * (1. + Q->q * sdsq)));
d = sqrt(Q->xj * Q->xj + s * s);
xy.x = Q->b * lamdp + Q->a2 * sin(2. * lamdp) + Q->a4 *
sin(lamdp * 4.) - tanph * s / d;
xy.y = Q->c1 * sd + Q->c3 * sin(lamdp * 3.) + tanph * Q->xj / d;
} else
xy.x = xy.y = HUGE_VAL;
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
int nn;
double lamt, sdsq, s, lamdp, phidp, sppsq, dd, sd, sl, fac, scl, sav, spp;
lamdp = xy.x / Q->b;
nn = 50;
do {
sav = lamdp;
sd = sin(lamdp);
sdsq = sd * sd;
s = Q->p22 * Q->sa * cos(lamdp) * sqrt((1. + Q->t * sdsq)
/ ((1. + Q->w * sdsq) * (1. + Q->q * sdsq)));
lamdp = xy.x + xy.y * s / Q->xj - Q->a2 * sin(
2. * lamdp) - Q->a4 * sin(lamdp * 4.) - s / Q->xj * (
Q->c1 * sin(lamdp) + Q->c3 * sin(lamdp * 3.));
lamdp /= Q->b;
} while (fabs(lamdp - sav) >= TOL && --nn);
sl = sin(lamdp);
fac = exp(sqrt(1. + s * s / Q->xj / Q->xj) * (xy.y -
Q->c1 * sl - Q->c3 * sin(lamdp * 3.)));
phidp = 2. * (atan(fac) - M_FORTPI);
dd = sl * sl;
if (fabs(cos(lamdp)) < TOL)
lamdp -= TOL;
spp = sin(phidp);
sppsq = spp * spp;
lamt = atan(((1. - sppsq * P->rone_es) * tan(lamdp) *
Q->ca - spp * Q->sa * sqrt((1. + Q->q * dd) * (
1. - sppsq) - sppsq * Q->u) / cos(lamdp)) / (1. - sppsq
* (1. + Q->u)));
sl = lamt >= 0. ? 1. : -1.;
scl = cos(lamdp) >= 0. ? 1. : -1;
lamt -= M_HALFPI * (1. - scl) * sl;
lp.lam = lamt - Q->p22 * lamdp;
if (fabs(Q->sa) < TOL)
lp.phi = aasin(P->ctx,spp / sqrt(P->one_es * P->one_es + P->es * sppsq));
else
lp.phi = atan((tan(lamdp) * cos(lamt) - Q->ca * sin(lamt)) /
(P->one_es * Q->sa));
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(lsat) {
int land, path;
double lam, alf, esc, ess;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
land = pj_param(P->ctx, P->params, "ilsat").i;
if (land <= 0 || land > 5) E_ERROR(-28);
path = pj_param(P->ctx, P->params, "ipath").i;
if (path <= 0 || path > (land <= 3 ? 251 : 233)) E_ERROR(-29);
if (land <= 3) {
P->lam0 = DEG_TO_RAD * 128.87 - M_TWOPI / 251. * path;
Q->p22 = 103.2669323;
alf = DEG_TO_RAD * 99.092;
} else {
P->lam0 = DEG_TO_RAD * 129.3 - M_TWOPI / 233. * path;
Q->p22 = 98.8841202;
alf = DEG_TO_RAD * 98.2;
}
Q->p22 /= 1440.;
Q->sa = sin(alf);
Q->ca = cos(alf);
if (fabs(Q->ca) < 1e-9)
Q->ca = 1e-9;
esc = P->es * Q->ca * Q->ca;
ess = P->es * Q->sa * Q->sa;
Q->w = (1. - esc) * P->rone_es;
Q->w = Q->w * Q->w - 1.;
Q->q = ess * P->rone_es;
Q->t = ess * (2. - P->es) * P->rone_es * P->rone_es;
Q->u = esc * P->rone_es;
Q->xj = P->one_es * P->one_es * P->one_es;
Q->rlm = M_PI * (1. / 248. + .5161290322580645);
Q->rlm2 = Q->rlm + M_TWOPI;
Q->a2 = Q->a4 = Q->b = Q->c1 = Q->c3 = 0.;
seraz0(0., 1., P);
for (lam = 9.; lam <= 81.0001; lam += 18.)
seraz0(lam, 4., P);
for (lam = 18; lam <= 72.0001; lam += 18.)
seraz0(lam, 2., P);
seraz0(90., 1., P);
Q->a2 /= 30.;
Q->a4 /= 60.;
Q->b /= 30.;
Q->c1 /= 15.;
Q->c3 /= 45.;
P->inv = e_inverse;
P->fwd = e_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_lsat_selftest (void) {return 0;}
#else
int pj_lsat_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=lsat +ellps=GRS80 +lat_1=0.5 +lat_2=2 +lsat=1 +path=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{18241950.01455855, 9998256.83982293494},
{18746856.2533194572, 10215761.669925211},
{18565503.6836331636, 9085039.14672705345},
{19019696.9020289108, 9247763.0394328218},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{126.000423834530011, 0.00172378224025701425},
{126.002213738256714, 0.00188015467480917966},
{126.000734468914601, -0.00188015467480917966},
{126.002524372641304, -0.00172378224025701425},
};
return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
}
#endif
proj-4.9.3/src/pj_msfn.c 0000644 0000000 0000000 00000000273 12761101536 011763 0000000 0000000 /* determine constant small m */
#include
#include
double
pj_msfn(double sinphi, double cosphi, double es) {
return (cosphi / sqrt (1. - es * sinphi * sinphi));
}
proj-4.9.3/src/geodesic.h 0000644 0000000 0000000 00000125473 12761101536 012130 0000000 0000000 /**
* \file geodesic.h
* \brief API for the geodesic routines in C
*
* This an implementation in C of the geodesic algorithms described in
* - C. F. F. Karney,
*
* Algorithms for geodesics,
* J. Geodesy 87, 43--55 (2013);
* DOI:
* 10.1007/s00190-012-0578-z;
* addenda:
* geod-addenda.html.
* .
* The principal advantages of these algorithms over previous ones (e.g.,
* Vincenty, 1975) are
* - accurate to round off for |f| < 1/50;
* - the solution of the inverse problem is always found;
* - differential and integral properties of geodesics are computed.
*
* The shortest path between two points on the ellipsoid at (\e lat1, \e
* lon1) and (\e lat2, \e lon2) is called the geodesic. Its length is
* \e s12 and the geodesic from point 1 to point 2 has forward azimuths
* \e azi1 and \e azi2 at the two end points.
*
* Traditionally two geodesic problems are considered:
* - the direct problem -- given \e lat1, \e lon1, \e s12, and \e azi1,
* determine \e lat2, \e lon2, and \e azi2. This is solved by the function
* geod_direct().
* - the inverse problem -- given \e lat1, \e lon1, and \e lat2, \e lon2,
* determine \e s12, \e azi1, and \e azi2. This is solved by the function
* geod_inverse().
*
* The ellipsoid is specified by its equatorial radius \e a (typically in
* meters) and flattening \e f. The routines are accurate to round off with
* double precision arithmetic provided that |f| < 1/50; for the
* WGS84 ellipsoid, the errors are less than 15 nanometers. (Reasonably
* accurate results are obtained for |f| < 1/5.) For a prolate
* ellipsoid, specify \e f < 0.
*
* The routines also calculate several other quantities of interest
* - \e S12 is the area between the geodesic from point 1 to point 2 and the
* equator; i.e., it is the area, measured counter-clockwise, of the
* quadrilateral with corners (\e lat1,\e lon1), (0,\e lon1), (0,\e lon2),
* and (\e lat2,\e lon2).
* - \e m12, the reduced length of the geodesic is defined such that if
* the initial azimuth is perturbed by \e dazi1 (radians) then the
* second point is displaced by \e m12 \e dazi1 in the direction
* perpendicular to the geodesic. On a curved surface the reduced
* length obeys a symmetry relation, \e m12 + \e m21 = 0. On a flat
* surface, we have \e m12 = \e s12.
* - \e M12 and \e M21 are geodesic scales. If two geodesics are
* parallel at point 1 and separated by a small distance \e dt, then
* they are separated by a distance \e M12 \e dt at point 2. \e M21
* is defined similarly (with the geodesics being parallel to one
* another at point 2). On a flat surface, we have \e M12 = \e M21
* = 1.
* - \e a12 is the arc length on the auxiliary sphere. This is a
* construct for converting the problem to one in spherical
* trigonometry. \e a12 is measured in degrees. The spherical arc
* length from one equator crossing to the next is always 180°.
*
* If points 1, 2, and 3 lie on a single geodesic, then the following
* addition rules hold:
* - \e s13 = \e s12 + \e s23
* - \e a13 = \e a12 + \e a23
* - \e S13 = \e S12 + \e S23
* - \e m13 = \e m12 \e M23 + \e m23 \e M21
* - \e M13 = \e M12 \e M23 − (1 − \e M12 \e M21) \e
* m23 / \e m12
* - \e M31 = \e M32 \e M21 − (1 − \e M23 \e M32) \e
* m12 / \e m23
*
* The shortest distance returned by the solution of the inverse problem is
* (obviously) uniquely defined. However, in a few special cases there are
* multiple azimuths which yield the same shortest distance. Here is a
* catalog of those cases:
* - \e lat1 = −\e lat2 (with neither point at a pole). If \e azi1 = \e
* azi2, the geodesic is unique. Otherwise there are two geodesics and the
* second one is obtained by setting [\e azi1, \e azi2] → [\e azi2, \e
* azi1], [\e M12, \e M21] → [\e M21, \e M12], \e S12 → −\e
* S12. (This occurs when the longitude difference is near ±180°
* for oblate ellipsoids.)
* - \e lon2 = \e lon1 ± 180° (with neither point at a pole). If \e
* azi1 = 0° or ±180°, the geodesic is unique. Otherwise
* there are two geodesics and the second one is obtained by setting [\e
* azi1, \e azi2] → [−\e azi1, −\e azi2], \e S12 →
* −\e S12. (This occurs when \e lat2 is near −\e lat1 for
* prolate ellipsoids.)
* - Points 1 and 2 at opposite poles. There are infinitely many geodesics
* which can be generated by setting [\e azi1, \e azi2] → [\e azi1, \e
* azi2] + [\e d, −\e d], for arbitrary \e d. (For spheres, this
* prescription applies when points 1 and 2 are antipodal.)
* - \e s12 = 0 (coincident points). There are infinitely many geodesics which
* can be generated by setting [\e azi1, \e azi2] → [\e azi1, \e azi2] +
* [\e d, \e d], for arbitrary \e d.
*
* These routines are a simple transcription of the corresponding C++ classes
* in GeographicLib. The
* "class data" is represented by the structs geod_geodesic, geod_geodesicline,
* geod_polygon and pointers to these objects are passed as initial arguments
* to the member functions. Most of the internal comments have been retained.
* However, in the process of transcription some documentation has been lost
* and the documentation for the C++ classes, GeographicLib::Geodesic,
* GeographicLib::GeodesicLine, and GeographicLib::PolygonAreaT, should be
* consulted. The C++ code remains the "reference implementation". Think
* twice about restructuring the internals of the C code since this may make
* porting fixes from the C++ code more difficult.
*
* Copyright (c) Charles Karney (2012-2016) and licensed
* under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/
*
* This library was distributed with
* GeographicLib 1.46.
**********************************************************************/
#if !defined(GEODESIC_H)
#define GEODESIC_H 1
/**
* The major version of the geodesic library. (This tracks the version of
* GeographicLib.)
**********************************************************************/
#define GEODESIC_VERSION_MAJOR 1
/**
* The minor version of the geodesic library. (This tracks the version of
* GeographicLib.)
**********************************************************************/
#define GEODESIC_VERSION_MINOR 46
/**
* The patch level of the geodesic library. (This tracks the version of
* GeographicLib.)
**********************************************************************/
#define GEODESIC_VERSION_PATCH 1
/**
* Pack the version components into a single integer. Users should not rely on
* this particular packing of the components of the version number; see the
* documentation for GEODESIC_VERSION, below.
**********************************************************************/
#define GEODESIC_VERSION_NUM(a,b,c) ((((a) * 10000 + (b)) * 100) + (c))
/**
* The version of the geodesic library as a single integer, packed as MMmmmmpp
* where MM is the major version, mmmm is the minor version, and pp is the
* patch level. Users should not rely on this particular packing of the
* components of the version number. Instead they should use a test such as
* @code{.c}
#if GEODESIC_VERSION >= GEODESIC_VERSION_NUM(1,40,0)
...
#endif
* @endcode
**********************************************************************/
#define GEODESIC_VERSION \
GEODESIC_VERSION_NUM(GEODESIC_VERSION_MAJOR, \
GEODESIC_VERSION_MINOR, \
GEODESIC_VERSION_PATCH)
#if defined(__cplusplus)
extern "C" {
#endif
/**
* The struct containing information about the ellipsoid. This must be
* initialized by geod_init() before use.
**********************************************************************/
struct geod_geodesic {
double a; /**< the equatorial radius */
double f; /**< the flattening */
/**< @cond SKIP */
double f1, e2, ep2, n, b, c2, etol2;
double A3x[6], C3x[15], C4x[21];
/**< @endcond */
};
/**
* The struct containing information about a single geodesic. This must be
* initialized by geod_lineinit(), geod_directline(), geod_gendirectline(),
* or geod_inverseline() before use.
**********************************************************************/
struct geod_geodesicline {
double lat1; /**< the starting latitude */
double lon1; /**< the starting longitude */
double azi1; /**< the starting azimuth */
double a; /**< the equatorial radius */
double f; /**< the flattening */
double salp1; /**< sine of \e azi1 */
double calp1; /**< cosine of \e azi1 */
double a13; /**< arc length to reference point */
double s13; /**< distance to reference point */
/**< @cond SKIP */
double b, c2, f1, salp0, calp0, k2,
ssig1, csig1, dn1, stau1, ctau1, somg1, comg1,
A1m1, A2m1, A3c, B11, B21, B31, A4, B41;
double C1a[6+1], C1pa[6+1], C2a[6+1], C3a[6], C4a[6];
/**< @endcond */
unsigned caps; /**< the capabilities */
};
/**
* The struct for accumulating information about a geodesic polygon. This is
* used for computing the perimeter and area of a polygon. This must be
* initialized by geod_polygon_init() before use.
**********************************************************************/
struct geod_polygon {
double lat; /**< the current latitude */
double lon; /**< the current longitude */
/**< @cond SKIP */
double lat0;
double lon0;
double A[2];
double P[2];
int polyline;
int crossings;
/**< @endcond */
unsigned num; /**< the number of points so far */
};
/**
* Initialize a geod_geodesic object.
*
* @param[out] g a pointer to the object to be initialized.
* @param[in] a the equatorial radius (meters).
* @param[in] f the flattening.
**********************************************************************/
void geod_init(struct geod_geodesic* g, double a, double f);
/**
* Solve the direct geodesic problem.
*
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] azi1 azimuth at point 1 (degrees).
* @param[in] s12 distance from point 1 to point 2 (meters); it can be
* negative.
* @param[out] plat2 pointer to the latitude of point 2 (degrees).
* @param[out] plon2 pointer to the longitude of point 2 (degrees).
* @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).
*
* \e g must have been initialized with a call to geod_init(). \e lat1
* should be in the range [−90°, 90°]. The values of \e lon2
* and \e azi2 returned are in the range [−180°, 180°). Any of
* the "return" arguments \e plat2, etc., may be replaced by 0, if you do not
* need some quantities computed.
*
* If either point is at a pole, the azimuth is defined by keeping the
* longitude fixed, writing \e lat = ±(90° − ε), and
* taking the limit ε → 0+. An arc length greater that 180°
* signifies a geodesic which is not a shortest path. (For a prolate
* ellipsoid, an additional condition is necessary for a shortest path: the
* longitudinal extent must not exceed of 180°.)
*
* Example, determine the point 10000 km NE of JFK:
@code{.c}
struct geod_geodesic g;
double lat, lon;
geod_init(&g, 6378137, 1/298.257223563);
geod_direct(&g, 40.64, -73.78, 45.0, 10e6, &lat, &lon, 0);
printf("%.5f %.5f\n", lat, lon);
@endcode
**********************************************************************/
void geod_direct(const struct geod_geodesic* g,
double lat1, double lon1, double azi1, double s12,
double* plat2, double* plon2, double* pazi2);
/**
* The general direct geodesic problem.
*
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] azi1 azimuth at point 1 (degrees).
* @param[in] flags bitor'ed combination of geod_flags(); \e flags &
* GEOD_ARCMODE determines the meaning of \e s12_a12 and \e flags &
* GEOD_LONG_UNROLL "unrolls" \e lon2.
* @param[in] s12_a12 if \e flags & GEOD_ARCMODE is 0, this is the distance
* from point 1 to point 2 (meters); otherwise it is the arc length
* from point 1 to point 2 (degrees); it can be negative.
* @param[out] plat2 pointer to the latitude of point 2 (degrees).
* @param[out] plon2 pointer to the longitude of point 2 (degrees).
* @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).
* @param[out] ps12 pointer to the distance from point 1 to point 2
* (meters).
* @param[out] pm12 pointer to the reduced length of geodesic (meters).
* @param[out] pM12 pointer to the geodesic scale of point 2 relative to
* point 1 (dimensionless).
* @param[out] pM21 pointer to the geodesic scale of point 1 relative to
* point 2 (dimensionless).
* @param[out] pS12 pointer to the area under the geodesic
* (meters2).
* @return \e a12 arc length from point 1 to point 2 (degrees).
*
* \e g must have been initialized with a call to geod_init(). \e lat1
* should be in the range [−90°, 90°]. The function value \e
* a12 equals \e s12_a12 if \e flags & GEOD_ARCMODE. Any of the "return"
* arguments, \e plat2, etc., may be replaced by 0, if you do not need some
* quantities computed.
*
* With \e flags & GEOD_LONG_UNROLL bit set, the longitude is "unrolled" so
* that the quantity \e lon2 − \e lon1 indicates how many times and in
* what sense the geodesic encircles the ellipsoid.
**********************************************************************/
double geod_gendirect(const struct geod_geodesic* g,
double lat1, double lon1, double azi1,
unsigned flags, double s12_a12,
double* plat2, double* plon2, double* pazi2,
double* ps12, double* pm12, double* pM12, double* pM21,
double* pS12);
/**
* Solve the inverse geodesic problem.
*
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] lat2 latitude of point 2 (degrees).
* @param[in] lon2 longitude of point 2 (degrees).
* @param[out] ps12 pointer to the distance from point 1 to point 2
* (meters).
* @param[out] pazi1 pointer to the azimuth at point 1 (degrees).
* @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).
*
* \e g must have been initialized with a call to geod_init(). \e lat1 and
* \e lat2 should be in the range [−90°, 90°]. The values of
* \e azi1 and \e azi2 returned are in the range [−180°, 180°).
* Any of the "return" arguments, \e ps12, etc., may be replaced by 0, if you
* do not need some quantities computed.
*
* If either point is at a pole, the azimuth is defined by keeping the
* longitude fixed, writing \e lat = ±(90° − ε), and
* taking the limit ε → 0+.
*
* The solution to the inverse problem is found using Newton's method. If
* this fails to converge (this is very unlikely in geodetic applications
* but does occur for very eccentric ellipsoids), then the bisection method
* is used to refine the solution.
*
* Example, determine the distance between JFK and Singapore Changi Airport:
@code{.c}
struct geod_geodesic g;
double s12;
geod_init(&g, 6378137, 1/298.257223563);
geod_inverse(&g, 40.64, -73.78, 1.36, 103.99, &s12, 0, 0);
printf("%.3f\n", s12);
@endcode
**********************************************************************/
void geod_inverse(const struct geod_geodesic* g,
double lat1, double lon1, double lat2, double lon2,
double* ps12, double* pazi1, double* pazi2);
/**
* The general inverse geodesic calculation.
*
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] lat2 latitude of point 2 (degrees).
* @param[in] lon2 longitude of point 2 (degrees).
* @param[out] ps12 pointer to the distance from point 1 to point 2
* (meters).
* @param[out] pazi1 pointer to the azimuth at point 1 (degrees).
* @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).
* @param[out] pm12 pointer to the reduced length of geodesic (meters).
* @param[out] pM12 pointer to the geodesic scale of point 2 relative to
* point 1 (dimensionless).
* @param[out] pM21 pointer to the geodesic scale of point 1 relative to
* point 2 (dimensionless).
* @param[out] pS12 pointer to the area under the geodesic
* (meters2).
* @return \e a12 arc length from point 1 to point 2 (degrees).
*
* \e g must have been initialized with a call to geod_init(). \e lat1 and
* \e lat2 should be in the range [−90°, 90°]. Any of the
* "return" arguments \e ps12, etc., may be replaced by 0, if you do not need
* some quantities computed.
**********************************************************************/
double geod_geninverse(const struct geod_geodesic* g,
double lat1, double lon1, double lat2, double lon2,
double* ps12, double* pazi1, double* pazi2,
double* pm12, double* pM12, double* pM21,
double* pS12);
/**
* Initialize a geod_geodesicline object.
*
* @param[out] l a pointer to the object to be initialized.
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] azi1 azimuth at point 1 (degrees).
* @param[in] caps bitor'ed combination of geod_mask() values specifying the
* capabilities the geod_geodesicline object should possess, i.e., which
* quantities can be returned in calls to geod_position() and
* geod_genposition().
*
* \e g must have been initialized with a call to geod_init(). \e lat1
* should be in the range [−90°, 90°].
*
* The geod_mask values are [see geod_mask()]:
* - \e caps |= GEOD_LATITUDE for the latitude \e lat2; this is
* added automatically,
* - \e caps |= GEOD_LONGITUDE for the latitude \e lon2,
* - \e caps |= GEOD_AZIMUTH for the latitude \e azi2; this is
* added automatically,
* - \e caps |= GEOD_DISTANCE for the distance \e s12,
* - \e caps |= GEOD_REDUCEDLENGTH for the reduced length \e m12,
* - \e caps |= GEOD_GEODESICSCALE for the geodesic scales \e M12
* and \e M21,
* - \e caps |= GEOD_AREA for the area \e S12,
* - \e caps |= GEOD_DISTANCE_IN permits the length of the
* geodesic to be given in terms of \e s12; without this capability the
* length can only be specified in terms of arc length.
* .
* A value of \e caps = 0 is treated as GEOD_LATITUDE | GEOD_LONGITUDE |
* GEOD_AZIMUTH | GEOD_DISTANCE_IN (to support the solution of the "standard"
* direct problem).
*
* When initialized by this function, point 3 is undefined (l->s13 = l->a13 =
* NaN).
**********************************************************************/
void geod_lineinit(struct geod_geodesicline* l,
const struct geod_geodesic* g,
double lat1, double lon1, double azi1, unsigned caps);
/**
* Initialize a geod_geodesicline object in terms of the direct geodesic
* problem.
*
* @param[out] l a pointer to the object to be initialized.
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] azi1 azimuth at point 1 (degrees).
* @param[in] s12 distance from point 1 to point 2 (meters); it can be
* negative.
* @param[in] caps bitor'ed combination of geod_mask() values specifying the
* capabilities the geod_geodesicline object should possess, i.e., which
* quantities can be returned in calls to geod_position() and
* geod_genposition().
*
* This function sets point 3 of the geod_geodesicline to correspond to point
* 2 of the direct geodesic problem. See geod_lineinit() for more
* informaion.
**********************************************************************/
void geod_directline(struct geod_geodesicline* l,
const struct geod_geodesic* g,
double lat1, double lon1, double azi1, double s12,
unsigned caps);
/**
* Initialize a geod_geodesicline object in terms of the direct geodesic
* problem spacified in terms of either distance or arc length.
*
* @param[out] l a pointer to the object to be initialized.
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] azi1 azimuth at point 1 (degrees).
* @param[in] flags either GEOD_NOFLAGS or GEOD_ARCMODE to determining the
* meaning of the \e s12_a12.
* @param[in] s12_a12 if \e flags = GEOD_NOFLAGS, this is the distance
* from point 1 to point 2 (meters); if \e flags = GEOD_ARCMODE, it is
* the arc length from point 1 to point 2 (degrees); it can be
* negative.
* @param[in] caps bitor'ed combination of geod_mask() values specifying the
* capabilities the geod_geodesicline object should possess, i.e., which
* quantities can be returned in calls to geod_position() and
* geod_genposition().
*
* This function sets point 3 of the geod_geodesicline to correspond to point
* 2 of the direct geodesic problem. See geod_lineinit() for more
* informaion.
**********************************************************************/
void geod_gendirectline(struct geod_geodesicline* l,
const struct geod_geodesic* g,
double lat1, double lon1, double azi1,
unsigned flags, double s12_a12,
unsigned caps);
/**
* Initialize a geod_geodesicline object in terms of the inverse geodesic
* problem.
*
* @param[out] l a pointer to the object to be initialized.
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in] lat1 latitude of point 1 (degrees).
* @param[in] lon1 longitude of point 1 (degrees).
* @param[in] lat2 latitude of point 2 (degrees).
* @param[in] lon2 longitude of point 2 (degrees).
* @param[in] caps bitor'ed combination of geod_mask() values specifying the
* capabilities the geod_geodesicline object should possess, i.e., which
* quantities can be returned in calls to geod_position() and
* geod_genposition().
*
* This function sets point 3 of the geod_geodesicline to correspond to point
* 2 of the inverse geodesic problem. See geod_lineinit() for more
* informaion.
**********************************************************************/
void geod_inverseline(struct geod_geodesicline* l,
const struct geod_geodesic* g,
double lat1, double lon1, double lat2, double lon2,
unsigned caps);
/**
* Compute the position along a geod_geodesicline.
*
* @param[in] l a pointer to the geod_geodesicline object specifying the
* geodesic line.
* @param[in] s12 distance from point 1 to point 2 (meters); it can be
* negative.
* @param[out] plat2 pointer to the latitude of point 2 (degrees).
* @param[out] plon2 pointer to the longitude of point 2 (degrees); requires
* that \e l was initialized with \e caps |= GEOD_LONGITUDE.
* @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).
*
* \e l must have been initialized with a call, e.g., to geod_lineinit(),
* with \e caps |= GEOD_DISTANCE_IN. The values of \e lon2 and \e azi2
* returned are in the range [−180°, 180°). Any of the
* "return" arguments \e plat2, etc., may be replaced by 0, if you do not
* need some quantities computed.
*
* Example, compute way points between JFK and Singapore Changi Airport
* the "obvious" way using geod_direct():
@code{.c}
struct geod_geodesic g;
double s12, azi1, lat[101],lon[101];
int i;
geod_init(&g, 6378137, 1/298.257223563);
geod_inverse(&g, 40.64, -73.78, 1.36, 103.99, &s12, &azi1, 0);
for (i = 0; i < 101; ++i) {
geod_direct(&g, 40.64, -73.78, azi1, i * s12 * 0.01, lat + i, lon + i, 0);
printf("%.5f %.5f\n", lat[i], lon[i]);
}
@endcode
* A faster way using geod_position():
@code{.c}
struct geod_geodesic g;
struct geod_geodesicline l;
double lat[101],lon[101];
int i;
geod_init(&g, 6378137, 1/298.257223563);
geod_inverseline(&l, &g, 40.64, -73.78, 1.36, 103.99, 0);
for (i = 0; i <= 100; ++i) {
geod_position(&l, i * l.s13 * 0.01, lat + i, lon + i, 0);
printf("%.5f %.5f\n", lat[i], lon[i]);
}
@endcode
**********************************************************************/
void geod_position(const struct geod_geodesicline* l, double s12,
double* plat2, double* plon2, double* pazi2);
/**
* The general position function.
*
* @param[in] l a pointer to the geod_geodesicline object specifying the
* geodesic line.
* @param[in] flags bitor'ed combination of geod_flags(); \e flags &
* GEOD_ARCMODE determines the meaning of \e s12_a12 and \e flags &
* GEOD_LONG_UNROLL "unrolls" \e lon2; if \e flags & GEOD_ARCMODE is 0,
* then \e l must have been initialized with \e caps |= GEOD_DISTANCE_IN.
* @param[in] s12_a12 if \e flags & GEOD_ARCMODE is 0, this is the
* distance from point 1 to point 2 (meters); otherwise it is the
* arc length from point 1 to point 2 (degrees); it can be
* negative.
* @param[out] plat2 pointer to the latitude of point 2 (degrees).
* @param[out] plon2 pointer to the longitude of point 2 (degrees); requires
* that \e l was initialized with \e caps |= GEOD_LONGITUDE.
* @param[out] pazi2 pointer to the (forward) azimuth at point 2 (degrees).
* @param[out] ps12 pointer to the distance from point 1 to point 2
* (meters); requires that \e l was initialized with \e caps |=
* GEOD_DISTANCE.
* @param[out] pm12 pointer to the reduced length of geodesic (meters);
* requires that \e l was initialized with \e caps |= GEOD_REDUCEDLENGTH.
* @param[out] pM12 pointer to the geodesic scale of point 2 relative to
* point 1 (dimensionless); requires that \e l was initialized with \e caps
* |= GEOD_GEODESICSCALE.
* @param[out] pM21 pointer to the geodesic scale of point 1 relative to
* point 2 (dimensionless); requires that \e l was initialized with \e caps
* |= GEOD_GEODESICSCALE.
* @param[out] pS12 pointer to the area under the geodesic
* (meters2); requires that \e l was initialized with \e caps |=
* GEOD_AREA.
* @return \e a12 arc length from point 1 to point 2 (degrees).
*
* \e l must have been initialized with a call to geod_lineinit() with \e
* caps |= GEOD_DISTANCE_IN. The value \e azi2 returned is in the range
* [−180°, 180°). Any of the "return" arguments \e plat2,
* etc., may be replaced by 0, if you do not need some quantities
* computed. Requesting a value which \e l is not capable of computing
* is not an error; the corresponding argument will not be altered.
*
* With \e flags & GEOD_LONG_UNROLL bit set, the longitude is "unrolled" so
* that the quantity \e lon2 − \e lon1 indicates how many times and in
* what sense the geodesic encircles the ellipsoid.
*
* Example, compute way points between JFK and Singapore Changi Airport using
* geod_genposition(). In this example, the points are evenly space in arc
* length (and so only approximately equally spaced in distance). This is
* faster than using geod_position() and would be appropriate if drawing the
* path on a map.
@code{.c}
struct geod_geodesic g;
struct geod_geodesicline l;
double lat[101], lon[101];
int i;
geod_init(&g, 6378137, 1/298.257223563);
geod_inverseline(&l, &g, 40.64, -73.78, 1.36, 103.99,
GEOD_LATITUDE | GEOD_LONGITUDE);
for (i = 0; i <= 100; ++i) {
geod_genposition(&l, GEOD_ARCMODE, i * l.a13 * 0.01,
lat + i, lon + i, 0, 0, 0, 0, 0, 0);
printf("%.5f %.5f\n", lat[i], lon[i]);
}
@endcode
**********************************************************************/
double geod_genposition(const struct geod_geodesicline* l,
unsigned flags, double s12_a12,
double* plat2, double* plon2, double* pazi2,
double* ps12, double* pm12,
double* pM12, double* pM21,
double* pS12);
/**
* Specify position of point 3 in terms of distance.
*
* @param[inout] l a pointer to the geod_geodesicline object.
* @param[in] s13 the distance from point 1 to point 3 (meters); it
* can be negative.
*
* This is only useful if the geod_geodesicline object has been constructed
* with \e caps |= GEOD_DISTANCE_IN.
**********************************************************************/
void geod_setdistance(struct geod_geodesicline* l, double s13);
/**
* Specify position of point 3 in terms of either distance or arc length.
*
* @param[inout] l a pointer to the geod_geodesicline object.
* @param[in] flags either GEOD_NOFLAGS or GEOD_ARCMODE to determining the
* meaning of the \e s13_a13.
* @param[in] s13_a13 if \e flags = GEOD_NOFLAGS, this is the distance
* from point 1 to point 3 (meters); if \e flags = GEOD_ARCMODE, it is
* the arc length from point 1 to point 3 (degrees); it can be
* negative.
*
* If flags = GEOD_NOFLAGS, this calls geod_setdistance(). If flags =
* GEOD_ARCMODE, the \e s13 is only set if the geod_geodesicline object has
* been constructed with \e caps |= GEOD_DISTANCE.
**********************************************************************/
void geod_gensetdistance(struct geod_geodesicline* l,
unsigned flags, double s13_a13);
/**
* Initialize a geod_polygon object.
*
* @param[out] p a pointer to the object to be initialized.
* @param[in] polylinep non-zero if a polyline instead of a polygon.
*
* If \e polylinep is zero, then the sequence of vertices and edges added by
* geod_polygon_addpoint() and geod_polygon_addedge() define a polygon and
* the perimeter and area are returned by geod_polygon_compute(). If \e
* polylinep is non-zero, then the vertices and edges define a polyline and
* only the perimeter is returned by geod_polygon_compute().
*
* The area and perimeter are accumulated at two times the standard floating
* point precision to guard against the loss of accuracy with many-sided
* polygons. At any point you can ask for the perimeter and area so far.
*
* An example of the use of this function is given in the documentation for
* geod_polygon_compute().
**********************************************************************/
void geod_polygon_init(struct geod_polygon* p, int polylinep);
/**
* Clear the polygon, allowing a new polygon to be started.
*
* @param[in,out] p a pointer to the object to be cleared.
**********************************************************************/
void geod_polygon_clear(struct geod_polygon* p);
/**
* Add a point to the polygon or polyline.
*
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in,out] p a pointer to the geod_polygon object specifying the
* polygon.
* @param[in] lat the latitude of the point (degrees).
* @param[in] lon the longitude of the point (degrees).
*
* \e g and \e p must have been initialized with calls to geod_init() and
* geod_polygon_init(), respectively. The same \e g must be used for all the
* points and edges in a polygon. \e lat should be in the range
* [−90°, 90°].
*
* An example of the use of this function is given in the documentation for
* geod_polygon_compute().
**********************************************************************/
void geod_polygon_addpoint(const struct geod_geodesic* g,
struct geod_polygon* p,
double lat, double lon);
/**
* Add an edge to the polygon or polyline.
*
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in,out] p a pointer to the geod_polygon object specifying the
* polygon.
* @param[in] azi azimuth at current point (degrees).
* @param[in] s distance from current point to next point (meters).
*
* \e g and \e p must have been initialized with calls to geod_init() and
* geod_polygon_init(), respectively. The same \e g must be used for all the
* points and edges in a polygon. This does nothing if no points have been
* added yet. The \e lat and \e lon fields of \e p give the location of the
* new vertex.
**********************************************************************/
void geod_polygon_addedge(const struct geod_geodesic* g,
struct geod_polygon* p,
double azi, double s);
/**
* Return the results for a polygon.
*
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in] p a pointer to the geod_polygon object specifying the polygon.
* @param[in] reverse if non-zero then clockwise (instead of
* counter-clockwise) traversal counts as a positive area.
* @param[in] sign if non-zero then return a signed result for the area if
* the polygon is traversed in the "wrong" direction instead of returning
* the area for the rest of the earth.
* @param[out] pA pointer to the area of the polygon (meters2);
* only set if \e polyline is non-zero in the call to geod_polygon_init().
* @param[out] pP pointer to the perimeter of the polygon or length of the
* polyline (meters).
* @return the number of points.
*
* The area and perimeter are accumulated at two times the standard floating
* point precision to guard against the loss of accuracy with many-sided
* polygons. Only simple polygons (which are not self-intersecting) are
* allowed. There's no need to "close" the polygon by repeating the first
* vertex. Set \e pA or \e pP to zero, if you do not want the corresponding
* quantity returned.
*
* More points can be added to the polygon after this call.
*
* Example, compute the perimeter and area of the geodesic triangle with
* vertices (0°N,0°E), (0°N,90°E), (90°N,0°E).
@code{.c}
double A, P;
int n;
struct geod_geodesic g;
struct geod_polygon p;
geod_init(&g, 6378137, 1/298.257223563);
geod_polygon_init(&p, 0);
geod_polygon_addpoint(&g, &p, 0, 0);
geod_polygon_addpoint(&g, &p, 0, 90);
geod_polygon_addpoint(&g, &p, 90, 0);
n = geod_polygon_compute(&g, &p, 0, 1, &A, &P);
printf("%d %.8f %.3f\n", n, P, A);
@endcode
**********************************************************************/
unsigned geod_polygon_compute(const struct geod_geodesic* g,
const struct geod_polygon* p,
int reverse, int sign,
double* pA, double* pP);
/**
* Return the results assuming a tentative final test point is added;
* however, the data for the test point is not saved. This lets you report a
* running result for the perimeter and area as the user moves the mouse
* cursor. Ordinary floating point arithmetic is used to accumulate the data
* for the test point; thus the area and perimeter returned are less accurate
* than if geod_polygon_addpoint() and geod_polygon_compute() are used.
*
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in] p a pointer to the geod_polygon object specifying the polygon.
* @param[in] lat the latitude of the test point (degrees).
* @param[in] lon the longitude of the test point (degrees).
* @param[in] reverse if non-zero then clockwise (instead of
* counter-clockwise) traversal counts as a positive area.
* @param[in] sign if non-zero then return a signed result for the area if
* the polygon is traversed in the "wrong" direction instead of returning
* the area for the rest of the earth.
* @param[out] pA pointer to the area of the polygon (meters2);
* only set if \e polyline is non-zero in the call to geod_polygon_init().
* @param[out] pP pointer to the perimeter of the polygon or length of the
* polyline (meters).
* @return the number of points.
*
* \e lat should be in the range [−90°, 90°].
**********************************************************************/
unsigned geod_polygon_testpoint(const struct geod_geodesic* g,
const struct geod_polygon* p,
double lat, double lon,
int reverse, int sign,
double* pA, double* pP);
/**
* Return the results assuming a tentative final test point is added via an
* azimuth and distance; however, the data for the test point is not saved.
* This lets you report a running result for the perimeter and area as the
* user moves the mouse cursor. Ordinary floating point arithmetic is used
* to accumulate the data for the test point; thus the area and perimeter
* returned are less accurate than if geod_polygon_addedge() and
* geod_polygon_compute() are used.
*
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in] p a pointer to the geod_polygon object specifying the polygon.
* @param[in] azi azimuth at current point (degrees).
* @param[in] s distance from current point to final test point (meters).
* @param[in] reverse if non-zero then clockwise (instead of
* counter-clockwise) traversal counts as a positive area.
* @param[in] sign if non-zero then return a signed result for the area if
* the polygon is traversed in the "wrong" direction instead of returning
* the area for the rest of the earth.
* @param[out] pA pointer to the area of the polygon (meters2);
* only set if \e polyline is non-zero in the call to geod_polygon_init().
* @param[out] pP pointer to the perimeter of the polygon or length of the
* polyline (meters).
* @return the number of points.
**********************************************************************/
unsigned geod_polygon_testedge(const struct geod_geodesic* g,
const struct geod_polygon* p,
double azi, double s,
int reverse, int sign,
double* pA, double* pP);
/**
* A simple interface for computing the area of a geodesic polygon.
*
* @param[in] g a pointer to the geod_geodesic object specifying the
* ellipsoid.
* @param[in] lats an array of latitudes of the polygon vertices (degrees).
* @param[in] lons an array of longitudes of the polygon vertices (degrees).
* @param[in] n the number of vertices.
* @param[out] pA pointer to the area of the polygon (meters2).
* @param[out] pP pointer to the perimeter of the polygon (meters).
*
* \e lats should be in the range [−90°, 90°].
*
* Only simple polygons (which are not self-intersecting) are allowed.
* There's no need to "close" the polygon by repeating the first vertex. The
* area returned is signed with counter-clockwise traversal being treated as
* positive.
*
* Example, compute the area of Antarctica:
@code{.c}
double
lats[] = {-72.9, -71.9, -74.9, -74.3, -77.5, -77.4, -71.7, -65.9, -65.7,
-66.6, -66.9, -69.8, -70.0, -71.0, -77.3, -77.9, -74.7},
lons[] = {-74, -102, -102, -131, -163, 163, 172, 140, 113,
88, 59, 25, -4, -14, -33, -46, -61};
struct geod_geodesic g;
double A, P;
geod_init(&g, 6378137, 1/298.257223563);
geod_polygonarea(&g, lats, lons, (sizeof lats) / (sizeof lats[0]), &A, &P);
printf("%.0f %.2f\n", A, P);
@endcode
**********************************************************************/
void geod_polygonarea(const struct geod_geodesic* g,
double lats[], double lons[], int n,
double* pA, double* pP);
/**
* mask values for the \e caps argument to geod_lineinit().
**********************************************************************/
enum geod_mask {
GEOD_NONE = 0U, /**< Calculate nothing */
GEOD_LATITUDE = 1U<<7 | 0U, /**< Calculate latitude */
GEOD_LONGITUDE = 1U<<8 | 1U<<3, /**< Calculate longitude */
GEOD_AZIMUTH = 1U<<9 | 0U, /**< Calculate azimuth */
GEOD_DISTANCE = 1U<<10 | 1U<<0, /**< Calculate distance */
GEOD_DISTANCE_IN = 1U<<11 | 1U<<0 | 1U<<1, /**< Allow distance as input */
GEOD_REDUCEDLENGTH= 1U<<12 | 1U<<0 | 1U<<2, /**< Calculate reduced length */
GEOD_GEODESICSCALE= 1U<<13 | 1U<<0 | 1U<<2, /**< Calculate geodesic scale */
GEOD_AREA = 1U<<14 | 1U<<4, /**< Calculate reduced length */
GEOD_ALL = 0x7F80U| 0x1FU /**< Calculate everything */
};
/**
* flag values for the \e flags argument to geod_gendirect() and
* geod_genposition()
**********************************************************************/
enum geod_flags {
GEOD_NOFLAGS = 0U, /**< No flags */
GEOD_ARCMODE = 1U<<0, /**< Position given in terms of arc distance */
GEOD_LONG_UNROLL = 1U<<15 /**< Unroll the longitude */
};
#if defined(__cplusplus)
}
#endif
#endif
proj-4.9.3/src/PJ_gnom.c 0000644 0000000 0000000 00000010711 12761101536 011656 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(gnom, "Gnomonic") "\n\tAzi, Sph.";
#define EPS10 1.e-10
#define N_POLE 0
#define S_POLE 1
#define EQUIT 2
#define OBLIQ 3
struct pj_opaque {
double sinph0;
double cosph0;
int mode;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double coslam, cosphi, sinphi;
sinphi = sin(lp.phi);
cosphi = cos(lp.phi);
coslam = cos(lp.lam);
switch (Q->mode) {
case EQUIT:
xy.y = cosphi * coslam;
break;
case OBLIQ:
xy.y = Q->sinph0 * sinphi + Q->cosph0 * cosphi * coslam;
break;
case S_POLE:
xy.y = - sinphi;
break;
case N_POLE:
xy.y = sinphi;
break;
}
if (xy.y <= EPS10) F_ERROR;
xy.x = (xy.y = 1. / xy.y) * cosphi * sin(lp.lam);
switch (Q->mode) {
case EQUIT:
xy.y *= sinphi;
break;
case OBLIQ:
xy.y *= Q->cosph0 * sinphi - Q->sinph0 * cosphi * coslam;
break;
case N_POLE:
coslam = - coslam;
case S_POLE:
xy.y *= cosphi * coslam;
break;
}
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double rh, cosz, sinz;
rh = hypot(xy.x, xy.y);
sinz = sin(lp.phi = atan(rh));
cosz = sqrt(1. - sinz * sinz);
if (fabs(rh) <= EPS10) {
lp.phi = P->phi0;
lp.lam = 0.;
} else {
switch (Q->mode) {
case OBLIQ:
lp.phi = cosz * Q->sinph0 + xy.y * sinz * Q->cosph0 / rh;
if (fabs(lp.phi) >= 1.)
lp.phi = lp.phi > 0. ? M_HALFPI : - M_HALFPI;
else
lp.phi = asin(lp.phi);
xy.y = (cosz - Q->sinph0 * sin(lp.phi)) * rh;
xy.x *= sinz * Q->cosph0;
break;
case EQUIT:
lp.phi = xy.y * sinz / rh;
if (fabs(lp.phi) >= 1.)
lp.phi = lp.phi > 0. ? M_HALFPI : - M_HALFPI;
else
lp.phi = asin(lp.phi);
xy.y = cosz * rh;
xy.x *= sinz;
break;
case S_POLE:
lp.phi -= M_HALFPI;
break;
case N_POLE:
lp.phi = M_HALFPI - lp.phi;
xy.y = -xy.y;
break;
}
lp.lam = atan2(xy.x, xy.y);
}
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(gnom) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
if (fabs(fabs(P->phi0) - M_HALFPI) < EPS10) {
Q->mode = P->phi0 < 0. ? S_POLE : N_POLE;
} else if (fabs(P->phi0) < EPS10) {
Q->mode = EQUIT;
} else {
Q->mode = OBLIQ;
Q->sinph0 = sin(P->phi0);
Q->cosph0 = cos(P->phi0);
}
P->inv = s_inverse;
P->fwd = s_forward;
P->es = 0.;
return P;
}
#ifndef PJ_SELFTEST
int pj_gnom_selftest (void) {return 0;}
#else
int pj_gnom_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=gnom +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 223492.92474718543, 111780.50920659291},
{ 223492.92474718543, -111780.50920659291},
{-223492.92474718543, 111780.50920659291},
{-223492.92474718543, -111780.50920659291},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.0017904931092009798, 0.00089524655438192376},
{ 0.0017904931092009798, -0.00089524655438192376},
{-0.0017904931092009798, 0.00089524655438192376},
{-0.0017904931092009798, -0.00089524655438192376},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_imw_p.c 0000644 0000000 0000000 00000013662 12761101536 012041 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(imw_p, "International Map of the World Polyconic")
"\n\tMod. Polyconic, Ell\n\tlat_1= and lat_2= [lon_1=]";
#define TOL 1e-10
#define EPS 1e-10
struct pj_opaque {
double P, Pp, Q, Qp, R_1, R_2, sphi_1, sphi_2, C2; \
double phi_1, phi_2, lam_1; \
double *en; \
int mode; /* = 0, phi_1 and phi_2 != 0, = 1, phi_1 = 0, = -1 phi_2 = 0 */
};
static int phi12(PJ *P, double *del, double *sig) {
struct pj_opaque *Q = P->opaque;
int err = 0;
if (!pj_param(P->ctx, P->params, "tlat_1").i ||
!pj_param(P->ctx, P->params, "tlat_2").i) {
err = -41;
} else {
Q->phi_1 = pj_param(P->ctx, P->params, "rlat_1").f;
Q->phi_2 = pj_param(P->ctx, P->params, "rlat_2").f;
*del = 0.5 * (Q->phi_2 - Q->phi_1);
*sig = 0.5 * (Q->phi_2 + Q->phi_1);
err = (fabs(*del) < EPS || fabs(*sig) < EPS) ? -42 : 0;
}
return err;
}
static XY loc_for(LP lp, PJ *P, double *yc) {
struct pj_opaque *Q = P->opaque;
XY xy;
if (! lp.phi) {
xy.x = lp.lam;
xy.y = 0.;
} else {
double xa, ya, xb, yb, xc, D, B, m, sp, t, R, C;
sp = sin(lp.phi);
m = pj_mlfn(lp.phi, sp, cos(lp.phi), Q->en);
xa = Q->Pp + Q->Qp * m;
ya = Q->P + Q->Q * m;
R = 1. / (tan(lp.phi) * sqrt(1. - P->es * sp * sp));
C = sqrt(R * R - xa * xa);
if (lp.phi < 0.) C = - C;
C += ya - R;
if (Q->mode < 0) {
xb = lp.lam;
yb = Q->C2;
} else {
t = lp.lam * Q->sphi_2;
xb = Q->R_2 * sin(t);
yb = Q->C2 + Q->R_2 * (1. - cos(t));
}
if (Q->mode > 0) {
xc = lp.lam;
*yc = 0.;
} else {
t = lp.lam * Q->sphi_1;
xc = Q->R_1 * sin(t);
*yc = Q->R_1 * (1. - cos(t));
}
D = (xb - xc)/(yb - *yc);
B = xc + D * (C + R - *yc);
xy.x = D * sqrt(R * R * (1 + D * D) - B * B);
if (lp.phi > 0)
xy.x = - xy.x;
xy.x = (B + xy.x) / (1. + D * D);
xy.y = sqrt(R * R - xy.x * xy.x);
if (lp.phi > 0)
xy.y = - xy.y;
xy.y += C + R;
}
return xy;
}
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
double yc;
xy = loc_for(lp, P, &yc);
return (xy);
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
XY t;
double yc;
lp.phi = Q->phi_2;
lp.lam = xy.x / cos(lp.phi);
do {
t = loc_for(lp, P, &yc);
lp.phi = ((lp.phi - Q->phi_1) * (xy.y - yc) / (t.y - yc)) + Q->phi_1;
lp.lam = lp.lam * xy.x / t.x;
} while (fabs(t.x - xy.x) > TOL || fabs(t.y - xy.y) > TOL);
return lp;
}
static void xy(PJ *P, double phi, double *x, double *y, double *sp, double *R) {
double F;
*sp = sin(phi);
*R = 1./(tan(phi) * sqrt(1. - P->es * *sp * *sp ));
F = P->opaque->lam_1 * *sp;
*y = *R * (1 - cos(F));
*x = *R * sin(F);
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(imw_p) {
double del, sig, s, t, x1, x2, T2, y1, m1, m2, y2;
int i;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
if (!(Q->en = pj_enfn(P->es))) E_ERROR_0;
if( (i = phi12(P, &del, &sig)) != 0)
E_ERROR(i);
if (Q->phi_2 < Q->phi_1) { /* make sure P->phi_1 most southerly */
del = Q->phi_1;
Q->phi_1 = Q->phi_2;
Q->phi_2 = del;
}
if (pj_param(P->ctx, P->params, "tlon_1").i)
Q->lam_1 = pj_param(P->ctx, P->params, "rlon_1").f;
else { /* use predefined based upon latitude */
sig = fabs(sig * RAD_TO_DEG);
if (sig <= 60) sig = 2.;
else if (sig <= 76) sig = 4.;
else sig = 8.;
Q->lam_1 = sig * DEG_TO_RAD;
}
Q->mode = 0;
if (Q->phi_1) xy(P, Q->phi_1, &x1, &y1, &Q->sphi_1, &Q->R_1);
else {
Q->mode = 1;
y1 = 0.;
x1 = Q->lam_1;
}
if (Q->phi_2) xy(P, Q->phi_2, &x2, &T2, &Q->sphi_2, &Q->R_2);
else {
Q->mode = -1;
T2 = 0.;
x2 = Q->lam_1;
}
m1 = pj_mlfn(Q->phi_1, Q->sphi_1, cos(Q->phi_1), Q->en);
m2 = pj_mlfn(Q->phi_2, Q->sphi_2, cos(Q->phi_2), Q->en);
t = m2 - m1;
s = x2 - x1;
y2 = sqrt(t * t - s * s) + y1;
Q->C2 = y2 - T2;
t = 1. / t;
Q->P = (m2 * y1 - m1 * y2) * t;
Q->Q = (y2 - y1) * t;
Q->Pp = (m2 * x1 - m1 * x2) * t;
Q->Qp = (x2 - x1) * t;
P->fwd = e_forward;
P->inv = e_inverse;
return P;
}
#ifndef PJ_SELFTEST
int pj_imw_p_selftest (void) {return 0;}
#else
int pj_imw_p_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=imw_p +ellps=GRS80 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222588.4411393762, 55321.128653809537},
{ 222756.90637768712, -165827.58428832365},
{-222588.4411393762, 55321.128653809537},
{-222756.90637768712, -165827.58428832365},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.0017966991379592214, 0.50090492361427374},
{ 0.0017966979081574697, 0.49909507588689922},
{-0.0017966991379592214, 0.50090492361427374},
{-0.0017966979081574697, 0.49909507588689922},
};
return pj_generic_selftest (e_args, 0, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, 0, inv_in, e_inv_expect, 0);
}
#endif
proj-4.9.3/src/PJ_nsper.c 0000644 0000000 0000000 00000015254 12761101536 012054 0000000 0000000 #define PJ_LIB__
#include
struct pj_opaque {
double height;
double sinph0;
double cosph0;
double p;
double rp;
double pn1;
double pfact;
double h;
double cg;
double sg;
double sw;
double cw;
int mode;
int tilt;
};
PROJ_HEAD(nsper, "Near-sided perspective") "\n\tAzi, Sph\n\th=";
PROJ_HEAD(tpers, "Tilted perspective") "\n\tAzi, Sph\n\ttilt= azi= h=";
# define EPS10 1.e-10
# define N_POLE 0
# define S_POLE 1
# define EQUIT 2
# define OBLIQ 3
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double coslam, cosphi, sinphi;
sinphi = sin(lp.phi);
cosphi = cos(lp.phi);
coslam = cos(lp.lam);
switch (Q->mode) {
case OBLIQ:
xy.y = Q->sinph0 * sinphi + Q->cosph0 * cosphi * coslam;
break;
case EQUIT:
xy.y = cosphi * coslam;
break;
case S_POLE:
xy.y = - sinphi;
break;
case N_POLE:
xy.y = sinphi;
break;
}
if (xy.y < Q->rp) F_ERROR;
xy.y = Q->pn1 / (Q->p - xy.y);
xy.x = xy.y * cosphi * sin(lp.lam);
switch (Q->mode) {
case OBLIQ:
xy.y *= (Q->cosph0 * sinphi -
Q->sinph0 * cosphi * coslam);
break;
case EQUIT:
xy.y *= sinphi;
break;
case N_POLE:
coslam = - coslam;
case S_POLE:
xy.y *= cosphi * coslam;
break;
}
if (Q->tilt) {
double yt, ba;
yt = xy.y * Q->cg + xy.x * Q->sg;
ba = 1. / (yt * Q->sw * Q->h + Q->cw);
xy.x = (xy.x * Q->cg - xy.y * Q->sg) * Q->cw * ba;
xy.y = yt * ba;
}
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double rh, cosz, sinz;
if (Q->tilt) {
double bm, bq, yt;
yt = 1./(Q->pn1 - xy.y * Q->sw);
bm = Q->pn1 * xy.x * yt;
bq = Q->pn1 * xy.y * Q->cw * yt;
xy.x = bm * Q->cg + bq * Q->sg;
xy.y = bq * Q->cg - bm * Q->sg;
}
rh = hypot(xy.x, xy.y);
if ((sinz = 1. - rh * rh * Q->pfact) < 0.) I_ERROR;
sinz = (Q->p - sqrt(sinz)) / (Q->pn1 / rh + rh / Q->pn1);
cosz = sqrt(1. - sinz * sinz);
if (fabs(rh) <= EPS10) {
lp.lam = 0.;
lp.phi = P->phi0;
} else {
switch (Q->mode) {
case OBLIQ:
lp.phi = asin(cosz * Q->sinph0 + xy.y * sinz * Q->cosph0 / rh);
xy.y = (cosz - Q->sinph0 * sin(lp.phi)) * rh;
xy.x *= sinz * Q->cosph0;
break;
case EQUIT:
lp.phi = asin(xy.y * sinz / rh);
xy.y = cosz * rh;
xy.x *= sinz;
break;
case N_POLE:
lp.phi = asin(cosz);
xy.y = -xy.y;
break;
case S_POLE:
lp.phi = - asin(cosz);
break;
}
lp.lam = atan2(xy.x, xy.y);
}
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
static PJ *setup(PJ *P) {
struct pj_opaque *Q = P->opaque;
if ((Q->height = pj_param(P->ctx, P->params, "dh").f) <= 0.) E_ERROR(-30);
if (fabs(fabs(P->phi0) - M_HALFPI) < EPS10)
Q->mode = P->phi0 < 0. ? S_POLE : N_POLE;
else if (fabs(P->phi0) < EPS10)
Q->mode = EQUIT;
else {
Q->mode = OBLIQ;
Q->sinph0 = sin(P->phi0);
Q->cosph0 = cos(P->phi0);
}
Q->pn1 = Q->height / P->a; /* normalize by radius */
Q->p = 1. + Q->pn1;
Q->rp = 1. / Q->p;
Q->h = 1. / Q->pn1;
Q->pfact = (Q->p + 1.) * Q->h;
P->inv = s_inverse;
P->fwd = s_forward;
P->es = 0.;
return P;
}
PJ *PROJECTION(nsper) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->tilt = 0;
return setup(P);
}
PJ *PROJECTION(tpers) {
double omega, gamma;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
omega = pj_param(P->ctx, P->params, "dtilt").f * DEG_TO_RAD;
gamma = pj_param(P->ctx, P->params, "dazi").f * DEG_TO_RAD;
Q->tilt = 1;
Q->cg = cos(gamma); Q->sg = sin(gamma);
Q->cw = cos(omega); Q->sw = sin(omega);
return setup(P);
}
#ifndef PJ_SELFTEST
int pj_nsper_selftest (void) {return 0;}
#else
int pj_nsper_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=nsper +a=6400000 +h=1000000"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 222239.816114099842, 111153.763991924759},
{ 222239.816114099842, -111153.763991924759},
{-222239.816114099842, 111153.763991924759},
{-222239.816114099842, -111153.763991924759},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00179049311728792437, 0.000895246558425396135},
{ 0.00179049311728792437, -0.000895246558425396135},
{-0.00179049311728792437, 0.000895246558425396135},
{-0.00179049311728792437, -0.000895246558425396135},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_tpers_selftest (void) {return 0;}
#else
int pj_tpers_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=tpers +a=6400000 +h=1000000 +azi=20"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 170820.288955531199, 180460.865555804776},
{ 246853.941538942483, -28439.8780357754222},
{-246853.941538942483, 28439.8780357754222},
{-170820.288955531199, -180460.865555804776}
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00198870552603137678, 0.000228871872278689991},
{ 0.00137632081376749859, -0.00145364129728205432},
{-0.00137632081376749859, 0.00145364129728205432},
{-0.00198870552603137678, -0.000228871872278689991},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_cea.c 0000644 0000000 0000000 00000007517 12761101536 011460 0000000 0000000 #define PJ_LIB__
#include
struct pj_opaque {
double qp;
double *apa;
};
PROJ_HEAD(cea, "Equal Area Cylindrical") "\n\tCyl, Sph&Ell\n\tlat_ts=";
# define EPS 1e-10
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
xy.x = P->k0 * lp.lam;
xy.y = 0.5 * pj_qsfn (sin (lp.phi), P->e, P->one_es) / P->k0;
return xy;
}
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
xy.x = P->k0 * lp.lam;
xy.y = sin(lp.phi) / P->k0;
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
lp.phi = pj_authlat(asin( 2. * xy.y * P->k0 / P->opaque->qp), P->opaque->apa);
lp.lam = xy.x / P->k0;
return lp;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
double t;
if ((t = fabs(xy.y *= P->k0)) - EPS <= 1.) {
if (t >= 1.)
lp.phi = xy.y < 0. ? -M_HALFPI : M_HALFPI;
else
lp.phi = asin(xy.y);
lp.lam = xy.x / P->k0;
} else I_ERROR;
return (lp);
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque->apa);
pj_dealloc (P->opaque);
return pj_dealloc (P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(cea) {
double t = 0.0;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
if (pj_param(P->ctx, P->params, "tlat_ts").i) {
P->k0 = cos(t = pj_param(P->ctx, P->params, "rlat_ts").f);
if (P->k0 < 0.) {
E_ERROR(-24);
}
}
if (P->es) {
t = sin(t);
P->k0 /= sqrt(1. - P->es * t * t);
P->e = sqrt(P->es);
if (!(Q->apa = pj_authset(P->es))) E_ERROR_0;
Q->qp = pj_qsfn(1., P->e, P->one_es);
P->inv = e_inverse;
P->fwd = e_forward;
} else {
P->inv = s_inverse;
P->fwd = s_forward;
}
return P;
}
#ifndef PJ_SELFTEST
int pj_cea_selftest (void) {return 0;}
#else
int pj_cea_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=cea +ellps=GRS80 +lat_1=0.5 +lat_2=2"};
char s_args[] = {"+proj=cea +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222638.981586547132, 110568.812396267356},
{ 222638.981586547132, -110568.812396265886},
{-222638.981586547132, 110568.812396267356},
{-222638.981586547132, -110568.812396265886},
};
XY s_fwd_expect[] = {
{ 223402.144255274179, 111695.401198614476},
{ 223402.144255274179, -111695.401198614476},
{-223402.144255274179, 111695.401198614476},
{-223402.144255274179, -111695.401198614476},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.00179663056823904264, 0.000904369476105564289},
{ 0.00179663056823904264, -0.000904369476105564289},
{-0.00179663056823904264, 0.000904369476105564289},
{-0.00179663056823904264, -0.000904369476105564289},
};
LP s_inv_expect[] = {
{ 0.00179049310978382265, 0.000895246554928338998},
{ 0.00179049310978382265, -0.000895246554928338998},
{-0.00179049310978382265, 0.000895246554928338998},
{-0.00179049310978382265, -0.000895246554928338998},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_putp6.c 0000644 0000000 0000000 00000010544 12761101536 012000 0000000 0000000 #define PJ_LIB__
#include
struct pj_opaque {
double C_x, C_y, A, B, D;
};
PROJ_HEAD(putp6, "Putnins P6") "\n\tPCyl., Sph.";
PROJ_HEAD(putp6p, "Putnins P6'") "\n\tPCyl., Sph.";
#define EPS 1e-10
#define NITER 10
#define CON_POLE 1.732050807568877
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double p, r, V;
int i;
p = Q->B * sin(lp.phi);
lp.phi *= 1.10265779;
for (i = NITER; i ; --i) {
r = sqrt(1. + lp.phi * lp.phi);
lp.phi -= V = ( (Q->A - r) * lp.phi - log(lp.phi + r) - p ) /
(Q->A - 2. * r);
if (fabs(V) < EPS)
break;
}
if (!i)
lp.phi = p < 0. ? -CON_POLE : CON_POLE;
xy.x = Q->C_x * lp.lam * (Q->D - sqrt(1. + lp.phi * lp.phi));
xy.y = Q->C_y * lp.phi;
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double r;
lp.phi = xy.y / Q->C_y;
r = sqrt(1. + lp.phi * lp.phi);
lp.lam = xy.x / (Q->C_x * (Q->D - r));
lp.phi = aasin( P->ctx, ( (Q->A - r) * lp.phi - log(lp.phi + r) ) / Q->B);
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(putp6) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->C_x = 1.01346;
Q->C_y = 0.91910;
Q->A = 4.;
Q->B = 2.1471437182129378784;
Q->D = 2.;
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
PJ *PROJECTION(putp6p) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->C_x = 0.44329;
Q->C_y = 0.80404;
Q->A = 6.;
Q->B = 5.61125;
Q->D = 3.;
P->es = 0.;
P->inv = s_inverse;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_putp6_selftest (void) {return 0;}
#else
int pj_putp6_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=putp6 +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 226369.395133402577, 110218.523796520662},
{ 226369.395133402577, -110218.523796520749},
{-226369.395133402577, 110218.523796520662},
{-226369.395133402577, -110218.523796520749},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00176671315102969921, 0.000907295534210503544},
{ 0.00176671315102969921, -0.000907295534205924308},
{-0.00176671315102969921, 0.000907295534210503544},
{-0.00176671315102969921, -0.000907295534205924308},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
#ifndef PJ_SELFTEST
int pj_putp6p_selftest (void) {return 0;}
#else
int pj_putp6p_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=putp6p +a=6400000 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 198034.195132195076, 125989.475461323193},
{ 198034.195132195076, -125989.475461323193},
{-198034.195132195076, 125989.475461323193},
{-198034.195132195076, -125989.475461323193},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP s_inv_expect[] = {
{ 0.00201955053120177067, 0.000793716441164738612},
{ 0.00201955053120177067, -0.000793716441164738612},
{-0.00201955053120177067, 0.000793716441164738612},
{-0.00201955053120177067, -0.000793716441164738612},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, inv_in, 0, s_inv_expect);
}
#endif
proj-4.9.3/src/PJ_lagrng.c 0000644 0000000 0000000 00000004317 12761101536 012175 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(lagrng, "Lagrange") "\n\tMisc Sph, no inv.\n\tW=";
#define TOL 1e-10
struct pj_opaque {
double a1;
double hrw;
double rw;
};
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double v, c;
if (fabs(fabs(lp.phi) - M_HALFPI) < TOL) {
xy.x = 0;
xy.y = lp.phi < 0 ? -2. : 2.;
} else {
lp.phi = sin(lp.phi);
v = Q->a1 * pow((1. + lp.phi)/(1. - lp.phi), Q->hrw);
if ((c = 0.5 * (v + 1./v) + cos(lp.lam *= Q->rw)) < TOL)
F_ERROR;
xy.x = 2. * sin(lp.lam) / c;
xy.y = (v - 1./v) / c;
}
return xy;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(lagrng) {
double phi1;
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
Q->rw = pj_param(P->ctx, P->params, "dW").f;
if (Q->rw <= 0) E_ERROR(-27);
Q->rw = 1. / Q->rw;
Q->hrw = 0.5 * Q->rw;
phi1 = sin(pj_param(P->ctx, P->params, "rlat_1").f);
if (fabs(fabs(phi1) - 1.) < TOL) E_ERROR(-22);
Q->a1 = pow((1. - phi1)/(1. + phi1), Q->hrw);
P->es = 0.;
P->fwd = s_forward;
return P;
}
#ifndef PJ_SELFTEST
int pj_lagrng_selftest (void) {return 0;}
#else
int pj_lagrng_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char s_args[] = {"+proj=lagrng +a=6400000 +W=2 +lat_1=0.5 +lat_2=2"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY s_fwd_expect[] = {
{ 111703.37591722561, 27929.8319080333386},
{ 111699.122088816002, -83784.1780133577704},
{-111703.37591722561, 27929.8319080333386},
{-111699.122088816002, -83784.1780133577704},
};
return pj_generic_selftest (0, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, 0, s_fwd_expect, 0, 0, 0);
}
#endif
proj-4.9.3/src/pj_pr_list.c 0000644 0000000 0000000 00000004533 12761101536 012477 0000000 0000000 /* print projection's list of parameters */
#include
#include
#include
#define LINE_LEN 72
static int
pr_list(PJ *P, int not_used) {
paralist *t;
int l, n = 1, flag = 0;
(void)putchar('#');
for (t = P->params; t; t = t->next)
if ((!not_used && t->used) || (not_used && !t->used)) {
l = strlen(t->param) + 1;
if (n + l > LINE_LEN) {
(void)fputs("\n#", stdout);
n = 2;
}
(void)putchar(' ');
if (*(t->param) != '+')
(void)putchar('+');
(void)fputs(t->param, stdout);
n += l;
} else
flag = 1;
if (n > 1)
(void)putchar('\n');
return flag;
}
void /* print link list of projection parameters */
pj_pr_list(PJ *P) {
char const *s;
(void)putchar('#');
for (s = P->descr; *s ; ++s) {
(void)putchar(*s);
if (*s == '\n')
(void)putchar('#');
}
(void)putchar('\n');
if (pr_list(P, 0)) {
(void)fputs("#--- following specified but NOT used\n", stdout);
(void)pr_list(P, 1);
}
}
/************************************************************************/
/* pj_get_def() */
/* */
/* Returns the PROJ.4 command string that would produce this */
/* definition expanded as much as possible. For instance, */
/* +init= calls and +datum= definitions would be expanded. */
/************************************************************************/
char *pj_get_def( PJ *P, int options )
{
paralist *t;
int l;
char *definition;
size_t def_max = 10;
(void) options;
definition = (char *) pj_malloc(def_max);
definition[0] = '\0';
for (t = P->params; t; t = t->next)
{
/* skip unused parameters ... mostly appended defaults and stuff */
if (!t->used)
continue;
/* grow the resulting string if needed */
l = strlen(t->param) + 1;
if( strlen(definition) + l + 5 > def_max )
{
char *def2;
def_max = def_max * 2 + l + 5;
def2 = (char *) pj_malloc(def_max);
strcpy( def2, definition );
pj_dalloc( definition );
definition = def2;
}
/* append this parameter */
strcat( definition, " +" );
strcat( definition, t->param );
}
return definition;
}
proj-4.9.3/src/PJ_tmerc.c 0000644 0000000 0000000 00000015666 12761101536 012046 0000000 0000000 #define PJ_LIB__
#include
PROJ_HEAD(tmerc, "Transverse Mercator") "\n\tCyl, Sph&Ell";
struct pj_opaque {
double esp; \
double ml0; \
double *en;
};
#define EPS10 1.e-10
#define FC1 1.
#define FC2 .5
#define FC3 .16666666666666666666
#define FC4 .08333333333333333333
#define FC5 .05
#define FC6 .03333333333333333333
#define FC7 .02380952380952380952
#define FC8 .01785714285714285714
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0, 0.0};
struct pj_opaque *Q = P->opaque;
double al, als, n, cosphi, sinphi, t;
/*
* Fail if our longitude is more than 90 degrees from the
* central meridian since the results are essentially garbage.
* Is error -20 really an appropriate return value?
*
* http://trac.osgeo.org/proj/ticket/5
*/
if( lp.lam < -M_HALFPI || lp.lam > M_HALFPI ) {
xy.x = HUGE_VAL;
xy.y = HUGE_VAL;
pj_ctx_set_errno( P->ctx, -14 );
return xy;
}
sinphi = sin (lp.phi);
cosphi = cos (lp.phi);
t = fabs (cosphi) > 1e-10 ? sinphi/cosphi : 0.;
t *= t;
al = cosphi * lp.lam;
als = al * al;
al /= sqrt (1. - P->es * sinphi * sinphi);
n = Q->esp * cosphi * cosphi;
xy.x = P->k0 * al * (FC1 +
FC3 * als * (1. - t + n +
FC5 * als * (5. + t * (t - 18.) + n * (14. - 58. * t)
+ FC7 * als * (61. + t * ( t * (179. - t) - 479. ) )
)));
xy.y = P->k0 * (pj_mlfn(lp.phi, sinphi, cosphi, Q->en) - Q->ml0 +
sinphi * al * lp.lam * FC2 * ( 1. +
FC4 * als * (5. - t + n * (9. + 4. * n) +
FC6 * als * (61. + t * (t - 58.) + n * (270. - 330 * t)
+ FC8 * als * (1385. + t * ( t * (543. - t) - 3111.) )
))));
return (xy);
}
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
double b, cosphi;
/*
* Fail if our longitude is more than 90 degrees from the
* central meridian since the results are essentially garbage.
* Is error -20 really an appropriate return value?
*
* http://trac.osgeo.org/proj/ticket/5
*/
if( lp.lam < -M_HALFPI || lp.lam > M_HALFPI ) {
xy.x = HUGE_VAL;
xy.y = HUGE_VAL;
pj_ctx_set_errno( P->ctx, -14 );
return xy;
}
cosphi = cos(lp.phi);
b = cosphi * sin (lp.lam);
if (fabs (fabs (b) - 1.) <= EPS10)
F_ERROR;
xy.x = P->opaque->ml0 * log ((1. + b) / (1. - b));
xy.y = cosphi * cos (lp.lam) / sqrt (1. - b * b);
b = fabs ( xy.y );
if (b >= 1.) {
if ((b - 1.) > EPS10)
F_ERROR
else xy.y = 0.;
} else
xy.y = acos (xy.y);
if (lp.phi < 0.)
xy.y = -xy.y;
xy.y = P->opaque->esp * (xy.y - P->phi0);
return xy;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double n, con, cosphi, d, ds, sinphi, t;
lp.phi = pj_inv_mlfn(P->ctx, Q->ml0 + xy.y / P->k0, P->es, Q->en);
if (fabs(lp.phi) >= M_HALFPI) {
lp.phi = xy.y < 0. ? -M_HALFPI : M_HALFPI;
lp.lam = 0.;
} else {
sinphi = sin(lp.phi);
cosphi = cos(lp.phi);
t = fabs (cosphi) > 1e-10 ? sinphi/cosphi : 0.;
n = Q->esp * cosphi * cosphi;
d = xy.x * sqrt (con = 1. - P->es * sinphi * sinphi) / P->k0;
con *= t;
t *= t;
ds = d * d;
lp.phi -= (con * ds / (1.-P->es)) * FC2 * (1. -
ds * FC4 * (5. + t * (3. - 9. * n) + n * (1. - 4 * n) -
ds * FC6 * (61. + t * (90. - 252. * n +
45. * t) + 46. * n
- ds * FC8 * (1385. + t * (3633. + t * (4095. + 1574. * t)) )
)));
lp.lam = d*(FC1 -
ds*FC3*( 1. + 2.*t + n -
ds*FC5*(5. + t*(28. + 24.*t + 8.*n) + 6.*n
- ds * FC7 * (61. + t * (662. + t * (1320. + 720. * t)) )
))) / cosphi;
}
return lp;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0, 0.0};
double h, g;
h = exp(xy.x / P->opaque->esp);
g = .5 * (h - 1. / h);
h = cos (P->phi0 + xy.y / P->opaque->esp);
lp.phi = asin(sqrt((1. - h * h) / (1. + g * g)));
if (xy.y < 0.) lp.phi = -lp.phi;
lp.lam = (g || h) ? atan2 (g, h) : 0.;
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque->en);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
static PJ *setup(PJ *P) { /* general initialization */
struct pj_opaque *Q = P->opaque;
if (P->es) {
if (!(Q->en = pj_enfn(P->es)))
E_ERROR_0;
Q->ml0 = pj_mlfn(P->phi0, sin(P->phi0), cos(P->phi0), Q->en);
Q->esp = P->es / (1. - P->es);
P->inv = e_inverse;
P->fwd = e_forward;
} else {
Q->esp = P->k0;
Q->ml0 = .5 * Q->esp;
P->inv = s_inverse;
P->fwd = s_forward;
}
return P;
}
PJ *PROJECTION(tmerc) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
return setup(P);
}
#ifndef PJ_SELFTEST
int pj_tmerc_selftest (void) {return 0;}
#else
int pj_tmerc_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=tmerc +ellps=GRS80 +lat_1=0.5 +lat_2=2 +n=0.5"};
char s_args[] = {"+proj=tmerc +a=6400000 +lat_1=0.5 +lat_2=2 +n=0.5"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222650.79679577847, 110642.22941192707},
{ 222650.79679577847, -110642.22941192707},
{-222650.79679577847, 110642.22941192707},
{-222650.79679577847, -110642.22941192707},
};
XY s_fwd_expect[] = {
{ 223413.46640632232, 111769.14504059685},
{ 223413.46640632232, -111769.14504059685},
{-223413.46640632208, 111769.14504059685},
{-223413.46640632208, -111769.14504059685},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.0017966305681649396, 0.00090436947663183841},
{ 0.0017966305681649396, -0.00090436947663183841},
{-0.0017966305681649396, 0.00090436947663183841},
{-0.0017966305681649396, -0.00090436947663183841},
};
LP s_inv_expect[] = {
{ 0.0017904931097048034, 0.00089524670602767842},
{ 0.0017904931097048034, -0.00089524670602767842},
{-0.001790493109714345, 0.00089524670602767842},
{-0.001790493109714345, -0.00089524670602767842},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
proj-4.9.3/src/pj_gridcatalog.c 0000644 0000000 0000000 00000022535 12761101536 013305 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Code in support of grid catalogs
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2012, 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.
*****************************************************************************/
#define PJ_LIB__
#include
#include
#include
static PJ_GridCatalog *grid_catalog_list = NULL;
/************************************************************************/
/* pj_gc_unloadall() */
/* */
/* Deallocate all the grid catalogs (but not the referenced */
/* grids). */
/************************************************************************/
void pj_gc_unloadall( projCtx ctx )
{
(void) ctx;
while( grid_catalog_list != NULL )
{
int i;
PJ_GridCatalog *catalog = grid_catalog_list;
grid_catalog_list = grid_catalog_list->next;
for( i = 0; i < catalog->entry_count; i++ )
{
/* we don't own gridinfo - do not free here */
free( catalog->entries[i].definition );
}
free( catalog->entries );
free( catalog );
}
}
/************************************************************************/
/* pj_gc_findcatalog() */
/************************************************************************/
PJ_GridCatalog *pj_gc_findcatalog( projCtx ctx, const char *name )
{
PJ_GridCatalog *catalog;
pj_acquire_lock();
for( catalog=grid_catalog_list; catalog != NULL; catalog = catalog->next )
{
if( strcmp(catalog->catalog_name, name) == 0 )
{
pj_release_lock();
return catalog;
}
}
pj_release_lock();
catalog = pj_gc_readcatalog( ctx, name );
if( catalog == NULL )
return NULL;
pj_acquire_lock();
catalog->next = grid_catalog_list;
grid_catalog_list = catalog;
pj_release_lock();
return catalog;
}
/************************************************************************/
/* pj_gc_apply_gridshift() */
/************************************************************************/
int pj_gc_apply_gridshift( PJ *defn, int inverse,
long point_count, int point_offset,
double *x, double *y, double *z )
{
int i;
(void) z;
if( defn->catalog == NULL )
{
defn->catalog = pj_gc_findcatalog( defn->ctx, defn->catalog_name );
if( defn->catalog == NULL )
return defn->ctx->last_errno;
}
defn->ctx->last_errno = 0;
for( i = 0; i < point_count; i++ )
{
long io = i * point_offset;
LP input, output_after, output_before;
double mix_ratio;
PJ_GRIDINFO *gi;
input.phi = y[io];
input.lam = x[io];
/* make sure we have appropriate "after" shift file available */
if( defn->last_after_grid == NULL
|| input.lam < defn->last_after_region.ll_long
|| input.lam > defn->last_after_region.ur_long
|| input.phi < defn->last_after_region.ll_lat
|| input.phi > defn->last_after_region.ll_lat ) {
defn->last_after_grid =
pj_gc_findgrid( defn->ctx, defn->catalog,
1, input, defn->datum_date,
&(defn->last_after_region),
&(defn->last_after_date));
}
gi = defn->last_after_grid;
assert( gi->child == NULL );
/* load the grid shift info if we don't have it. */
if( gi->ct->cvs == NULL && !pj_gridinfo_load( defn->ctx, gi ) )
{
pj_ctx_set_errno( defn->ctx, -38 );
return -38;
}
output_after = nad_cvt( input, inverse, gi->ct );
if( output_after.lam == HUGE_VAL )
{
if( defn->ctx->debug_level >= PJ_LOG_DEBUG_MAJOR )
{
pj_log( defn->ctx, PJ_LOG_DEBUG_MAJOR,
"pj_apply_gridshift(): failed to find a grid shift table for\n"
" location (%.7fdW,%.7fdN)",
x[io] * RAD_TO_DEG,
y[io] * RAD_TO_DEG );
}
continue;
}
if( defn->datum_date == 0.0 )
{
y[io] = output_after.phi;
x[io] = output_after.lam;
continue;
}
/* make sure we have appropriate "before" shift file available */
if( defn->last_before_grid == NULL
|| input.lam < defn->last_before_region.ll_long
|| input.lam > defn->last_before_region.ur_long
|| input.phi < defn->last_before_region.ll_lat
|| input.phi > defn->last_before_region.ll_lat ) {
defn->last_before_grid =
pj_gc_findgrid( defn->ctx, defn->catalog,
0, input, defn->datum_date,
&(defn->last_before_region),
&(defn->last_before_date));
}
gi = defn->last_before_grid;
assert( gi->child == NULL );
/* load the grid shift info if we don't have it. */
if( gi->ct->cvs == NULL && !pj_gridinfo_load( defn->ctx, gi ) )
{
pj_ctx_set_errno( defn->ctx, -38 );
return -38;
}
output_before = nad_cvt( input, inverse, gi->ct );
if( output_before.lam == HUGE_VAL )
{
if( defn->ctx->debug_level >= PJ_LOG_DEBUG_MAJOR )
{
pj_log( defn->ctx, PJ_LOG_DEBUG_MAJOR,
"pj_apply_gridshift(): failed to find a grid shift table for\n"
" location (%.7fdW,%.7fdN)",
x[io] * RAD_TO_DEG,
y[io] * RAD_TO_DEG );
}
continue;
}
mix_ratio = (defn->datum_date - defn->last_before_date)
/ (defn->last_after_date - defn->last_before_date);
y[io] = mix_ratio * output_after.phi
+ (1.0-mix_ratio) * output_before.phi;
x[io] = mix_ratio * output_after.lam
+ (1.0-mix_ratio) * output_before.lam;
}
return 0;
}
/************************************************************************/
/* pj_c_findgrid() */
/************************************************************************/
PJ_GRIDINFO *pj_gc_findgrid( projCtx ctx, PJ_GridCatalog *catalog, int after,
LP location, double date,
PJ_Region *optimal_region,
double *grid_date )
{
int iEntry;
PJ_GridCatalogEntry *entry = NULL;
for( iEntry = 0; iEntry < catalog->entry_count; iEntry++ )
{
entry = catalog->entries + iEntry;
if( (after && entry->date < date)
|| (!after && entry->date > date) )
continue;
if( location.lam < entry->region.ll_long
|| location.lam > entry->region.ur_long
|| location.phi < entry->region.ll_lat
|| location.phi > entry->region.ur_lat )
continue;
if( entry->available == -1 )
continue;
break;
}
if( iEntry == catalog->entry_count )
{
if( grid_date )
*grid_date = 0.0;
if( optimal_region != NULL )
memset( optimal_region, 0, sizeof(PJ_Region));
return NULL;
}
if( grid_date )
*grid_date = entry->date;
if( optimal_region )
{
}
if( entry->gridinfo == NULL )
{
PJ_GRIDINFO **gridlist = NULL;
int grid_count = 0;
gridlist = pj_gridlist_from_nadgrids( ctx, entry->definition,
&grid_count);
if( grid_count == 1 )
entry->gridinfo = gridlist[0];
}
return entry->gridinfo;
}
proj-4.9.3/src/pj_apply_vgridshift.c 0000644 0000000 0000000 00000017607 12761101536 014407 0000000 0000000 /******************************************************************************
* Project: PROJ.4
* Purpose: Apply vertical datum shifts based on grid shift files, normally
* geoid grids mapping WGS84 to NAVD88 or something similar.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2010, 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.
*****************************************************************************/
#define PJ_LIB__
#include
#include
#include
/************************************************************************/
/* pj_apply_vgridshift() */
/* */
/* This implmentation takes uses the gridlist from a coordinate */
/* system definition. If the gridlist has not yet been */
/* populated in the coordinate system definition we set it up */
/* now. */
/************************************************************************/
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 i;
static int debug_count = 0;
PJ_GRIDINFO **tables;
if( *gridlist_p == NULL )
{
*gridlist_p =
pj_gridlist_from_nadgrids( pj_get_ctx(defn),
pj_param(defn->ctx,defn->params,listname).s,
gridlist_count_p );
if( *gridlist_p == NULL || *gridlist_count_p == 0 )
return defn->ctx->last_errno;
}
if( *gridlist_count_p == 0 )
{
pj_ctx_set_errno( defn->ctx, -38);
return -38;
}
tables = *gridlist_p;
defn->ctx->last_errno = 0;
for( i = 0; i < point_count; i++ )
{
long io = i * point_offset;
LP input;
int itable;
double value = HUGE_VAL;
input.phi = y[io];
input.lam = x[io];
/* keep trying till we find a table that works */
for( itable = 0; itable < *gridlist_count_p; itable++ )
{
PJ_GRIDINFO *gi = tables[itable];
struct CTABLE *ct = gi->ct;
double grid_x, grid_y;
int grid_ix, grid_iy;
float *cvs;
/* skip tables that don't match our point at all. */
if( ct->ll.phi > input.phi || ct->ll.lam > input.lam
|| ct->ll.phi + (ct->lim.phi-1) * ct->del.phi < input.phi
|| ct->ll.lam + (ct->lim.lam-1) * ct->del.lam < input.lam )
continue;
/* If we have child nodes, check to see if any of them apply. */
while( gi->child != NULL )
{
PJ_GRIDINFO *child;
for( child = gi->child; child != NULL; child = child->next )
{
struct CTABLE *ct1 = child->ct;
if( ct1->ll.phi > input.phi || ct1->ll.lam > input.lam
|| ct1->ll.phi+(ct1->lim.phi-1)*ct1->del.phi < input.phi
|| ct1->ll.lam+(ct1->lim.lam-1)*ct1->del.lam < input.lam)
continue;
break;
}
/* we didn't find a more refined child node to use, so go with current grid */
if( child == NULL )
{
break;
}
/* Otherwise let's try for childrens children .. */
gi = child;
ct = child->ct;
}
/* load the grid shift info if we don't have it. */
if( ct->cvs == NULL && !pj_gridinfo_load( pj_get_ctx(defn), gi ) )
{
pj_ctx_set_errno( defn->ctx, -38 );
return -38;
}
/* Interpolation a location within the grid */
grid_x = (input.lam - ct->ll.lam) / ct->del.lam;
grid_y = (input.phi - ct->ll.phi) / ct->del.phi;
grid_ix = (int) floor(grid_x);
grid_iy = (int) floor(grid_y);
grid_x -= grid_ix;
grid_y -= grid_iy;
cvs = (float *) ct->cvs;
value = cvs[grid_ix + grid_iy * ct->lim.lam]
* (1.0-grid_x) * (1.0-grid_y)
+ cvs[grid_ix + 1 + grid_iy * ct->lim.lam]
* (grid_x) * (1.0-grid_y)
+ cvs[grid_ix + (grid_iy+1) * ct->lim.lam]
* (1.0-grid_x) * (grid_y)
+ cvs[grid_ix + 1 + (grid_iy+1) * ct->lim.lam]
* (grid_x) * (grid_y);
/* nodata? */
/* GTX official nodata value if -88.88880f, but some grids also */
/* use other big values for nodata (e.g naptrans2008.gtx has */
/* nodata values like -2147479936), so test them too */
if( value > 1000 || value < -1000 || value == -88.88880f )
value = HUGE_VAL;
else
{
if( inverse )
z[io] -= value;
else
z[io] += value;
}
if( value != HUGE_VAL )
{
if( debug_count++ < 20 )
pj_log( defn->ctx, PJ_LOG_DEBUG_MINOR,
"pj_apply_gridshift(): used %s",
ct->id );
break;
}
}
if( value == HUGE_VAL )
{
char gridlist[3000];
pj_log( defn->ctx, PJ_LOG_DEBUG_MAJOR,
"pj_apply_vgridshift(): failed to find a grid shift table for\n"
" location (%.7fdW,%.7fdN)",
x[io] * RAD_TO_DEG,
y[io] * RAD_TO_DEG );
gridlist[0] = '\0';
for( itable = 0; itable < *gridlist_count_p; itable++ )
{
PJ_GRIDINFO *gi = tables[itable];
if( strlen(gridlist) + strlen(gi->gridname) > sizeof(gridlist)-100 )
{
strcat( gridlist, "..." );
break;
}
if( itable == 0 )
sprintf( gridlist, " tried: %s", gi->gridname );
else
sprintf( gridlist+strlen(gridlist), ",%s", gi->gridname );
}
pj_log( defn->ctx, PJ_LOG_DEBUG_MAJOR,
"%s", gridlist );
pj_ctx_set_errno( defn->ctx, PJD_ERR_GRID_AREA );
return PJD_ERR_GRID_AREA;
}
}
return 0;
}
proj-4.9.3/src/PJ_geos.c 0000644 0000000 0000000 00000021020 12761101536 011646 0000000 0000000 /*
** libproj -- library of cartographic projections
**
** Copyright (c) 2004 Gerald I. Evenden
** Copyright (c) 2012 Martin Raspaud
**
** See also (section 4.4.3.2):
** http://www.eumetsat.int/en/area4/msg/news/us_doc/cgms_03_26.pdf
**
** 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.
*/
#define PJ_LIB__
#include
struct pj_opaque {
double h;
double radius_p;
double radius_p2;
double radius_p_inv2;
double radius_g;
double radius_g_1;
double C;
char *sweep_axis;
int flip_axis;
};
PROJ_HEAD(geos, "Geostationary Satellite View") "\n\tAzi, Sph&Ell\n\th=";
static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double Vx, Vy, Vz, tmp;
/* Calculation of the three components of the vector from satellite to
** position on earth surface (lon,lat).*/
tmp = cos(lp.phi);
Vx = cos (lp.lam) * tmp;
Vy = sin (lp.lam) * tmp;
Vz = sin (lp.phi);
/* Check visibility*/
/* Calculation based on view angles from satellite.*/
tmp = Q->radius_g - Vx;
if(Q->flip_axis) {
xy.x = Q->radius_g_1 * atan(Vy / hypot(Vz, tmp));
xy.y = Q->radius_g_1 * atan(Vz / tmp);
} else {
xy.x = Q->radius_g_1 * atan(Vy / tmp);
xy.y = Q->radius_g_1 * atan(Vz / hypot(Vy, tmp));
}
return xy;
}
static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
XY xy = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double r, Vx, Vy, Vz, tmp;
/* Calculation of geocentric latitude. */
lp.phi = atan (Q->radius_p2 * tan (lp.phi));
/* Calculation of the three components of the vector from satellite to
** position on earth surface (lon,lat).*/
r = (Q->radius_p) / hypot(Q->radius_p * cos (lp.phi), sin (lp.phi));
Vx = r * cos (lp.lam) * cos (lp.phi);
Vy = r * sin (lp.lam) * cos (lp.phi);
Vz = r * sin (lp.phi);
/* Check visibility. */
if (((Q->radius_g - Vx) * Vx - Vy * Vy - Vz * Vz * Q->radius_p_inv2) < 0.)
F_ERROR;
/* Calculation based on view angles from satellite. */
tmp = Q->radius_g - Vx;
if(Q->flip_axis) {
xy.x = Q->radius_g_1 * atan (Vy / hypot (Vz, tmp));
xy.y = Q->radius_g_1 * atan (Vz / tmp);
} else {
xy.x = Q->radius_g_1 * atan (Vy / tmp);
xy.y = Q->radius_g_1 * atan (Vz / hypot (Vy, tmp));
}
return xy;
}
static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double Vx, Vy, Vz, a, b, det, k;
/* Setting three components of vector from satellite to position.*/
Vx = -1.0;
if(Q->flip_axis) {
Vz = tan (xy.y / (Q->radius_g - 1.0));
Vy = tan (xy.x / (Q->radius_g - 1.0)) * sqrt (1.0 + Vz * Vz);
} else {
Vy = tan (xy.x / (Q->radius_g - 1.0));
Vz = tan (xy.y / (Q->radius_g - 1.0)) * sqrt (1.0 + Vy * Vy);
}
/* Calculation of terms in cubic equation and determinant.*/
a = Vy * Vy + Vz * Vz + Vx * Vx;
b = 2 * Q->radius_g * Vx;
if ((det = (b * b) - 4 * a * Q->C) < 0.) I_ERROR;
/* Calculation of three components of vector from satellite to position.*/
k = (-b - sqrt(det)) / (2 * a);
Vx = Q->radius_g + k * Vx;
Vy *= k;
Vz *= k;
/* Calculation of longitude and latitude.*/
lp.lam = atan2 (Vy, Vx);
lp.phi = atan (Vz * cos (lp.lam) / Vx);
return lp;
}
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
LP lp = {0.0,0.0};
struct pj_opaque *Q = P->opaque;
double Vx, Vy, Vz, a, b, det, k;
/* Setting three components of vector from satellite to position.*/
Vx = -1.0;
if(Q->flip_axis) {
Vz = tan (xy.y / Q->radius_g_1);
Vy = tan (xy.x / Q->radius_g_1) * hypot(1.0, Vz);
} else {
Vy = tan (xy.x / Q->radius_g_1);
Vz = tan (xy.y / Q->radius_g_1) * hypot(1.0, Vy);
}
/* Calculation of terms in cubic equation and determinant.*/
a = Vz / Q->radius_p;
a = Vy * Vy + a * a + Vx * Vx;
b = 2 * Q->radius_g * Vx;
if ((det = (b * b) - 4 * a * Q->C) < 0.) I_ERROR;
/* Calculation of three components of vector from satellite to position.*/
k = (-b - sqrt(det)) / (2. * a);
Vx = Q->radius_g + k * Vx;
Vy *= k;
Vz *= k;
/* Calculation of longitude and latitude.*/
lp.lam = atan2 (Vy, Vx);
lp.phi = atan (Vz * cos (lp.lam) / Vx);
lp.phi = atan (Q->radius_p_inv2 * tan (lp.phi));
return lp;
}
static void *freeup_new (PJ *P) { /* Destructor */
if (0==P)
return 0;
if (0==P->opaque)
return pj_dealloc (P);
pj_dealloc (P->opaque);
return pj_dealloc(P);
}
static void freeup (PJ *P) {
freeup_new (P);
return;
}
PJ *PROJECTION(geos) {
struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
if (0==Q)
return freeup_new (P);
P->opaque = Q;
if ((Q->h = pj_param(P->ctx, P->params, "dh").f) <= 0.) E_ERROR(-30);
if (P->phi0) E_ERROR(-46);
Q->sweep_axis = pj_param(P->ctx, P->params, "ssweep").s;
if (Q->sweep_axis == NULL)
Q->flip_axis = 0;
else {
if (Q->sweep_axis[1] != '\0' ||
(Q->sweep_axis[0] != 'x' &&
Q->sweep_axis[0] != 'y'))
E_ERROR(-49);
if (Q->sweep_axis[0] == 'x')
Q->flip_axis = 1;
else
Q->flip_axis = 0;
}
Q->radius_g_1 = Q->h / P->a;
Q->radius_g = 1. + Q->radius_g_1;
Q->C = Q->radius_g * Q->radius_g - 1.0;
if (P->es) {
Q->radius_p = sqrt (P->one_es);
Q->radius_p2 = P->one_es;
Q->radius_p_inv2 = P->rone_es;
P->inv = e_inverse;
P->fwd = e_forward;
} else {
Q->radius_p = Q->radius_p2 = Q->radius_p_inv2 = 1.0;
P->inv = s_inverse;
P->fwd = s_forward;
}
return P;
}
#ifndef PJ_SELFTEST
int pj_geos_selftest (void) {return 0;}
#else
int pj_geos_selftest (void) {
double tolerance_lp = 1e-10;
double tolerance_xy = 1e-7;
char e_args[] = {"+proj=geos +ellps=GRS80 +lat_1=0.5 +lat_2=2 +h=35785831"};
char s_args[] = {"+proj=geos +a=6400000 +lat_1=0.5 +lat_2=2 +h=35785831"};
LP fwd_in[] = {
{ 2, 1},
{ 2,-1},
{-2, 1},
{-2,-1}
};
XY e_fwd_expect[] = {
{ 222527.07036580026, 110551.30341332949},
{ 222527.07036580026, -110551.30341332949},
{-222527.07036580026, 110551.30341332949},
{-222527.07036580026, -110551.30341332949},
};
XY s_fwd_expect[] = {
{ 223289.45763579503, 111677.65745653701},
{ 223289.45763579503, -111677.65745653701},
{-223289.45763579503, 111677.65745653701},
{-223289.45763579503, -111677.65745653701},
};
XY inv_in[] = {
{ 200, 100},
{ 200,-100},
{-200, 100},
{-200,-100}
};
LP e_inv_expect[] = {
{ 0.0017966305689715385, 0.00090436947723267452},
{ 0.0017966305689715385, -0.00090436947723267452},
{-0.0017966305689715385, 0.00090436947723267452},
{-0.0017966305689715385, -0.00090436947723267452},
};
LP s_inv_expect[] = {
{ 0.0017904931105078943, 0.00089524655504237148},
{ 0.0017904931105078943, -0.00089524655504237148},
{-0.0017904931105078943, 0.00089524655504237148},
{-0.0017904931105078943, -0.00089524655504237148},
};
return pj_generic_selftest (e_args, s_args, tolerance_xy, tolerance_lp, 4, 4, fwd_in, e_fwd_expect, s_fwd_expect, inv_in, e_inv_expect, s_inv_expect);
}
#endif
proj-4.9.3/src/pj_fwd3d.c 0000644 0000000 0000000 00000002657 12761101536 012037 0000000 0000000 /* general forward projection */
#define PJ_LIB__
#include
#include
# define EPS 1.0e-12
XYZ /* forward projection entry */
pj_fwd3d(LPZ lpz, PJ *P) {
XYZ xyz;
double t;
/* check for forward and latitude or longitude overange */
if ((t = fabs(lpz.phi)-M_HALFPI) > EPS || fabs(lpz.lam) > 10.) {
xyz.x = xyz.y = xyz.z = HUGE_VAL;
pj_ctx_set_errno( P->ctx, -14);
} else { /* proceed with projection */
P->ctx->last_errno = 0;
pj_errno = 0;
errno = 0;
if (fabs(t) <= EPS)
lpz.phi = lpz.phi < 0. ? -M_HALFPI : M_HALFPI;
else if (P->geoc) /* Maybe redundant and never used. */
lpz.phi = atan(P->rone_es * tan(lpz.phi));
lpz.lam -= P->lam0; /* compute del lp.lam */
if (!P->over)
lpz.lam = adjlon(lpz.lam); /* adjust del longitude */
/* Check for NULL pointer */
if (P->fwd3d != NULL)
{
xyz = (*P->fwd3d)(lpz, P); /* project */
if ( P->ctx->last_errno )
xyz.x = xyz.y = xyz.z = HUGE_VAL;
/* adjust for major axis and easting/northings */
else {
xyz.x = P->fr_meter * (P->a * xyz.x + P->x0);
xyz.y = P->fr_meter * (P->a * xyz.y + P->y0);
/* z is not scaled since this handled by vto_meter outside */
}
}
else
{
xyz.x = xyz.y = xyz.z = HUGE_VAL;
}
}
return xyz;
}
proj-4.9.3/src/PJ_chamb.c 0000644 0000000 0000000 00000011745 12761101536 012000 0000000 0000000 #define PJ_LIB__
#include