diff options
| author | Kurt Schwehr <schwehr@google.com> | 2018-05-04 16:17:33 -0700 |
|---|---|---|
| committer | Kurt Schwehr <schwehr@google.com> | 2018-05-04 16:17:33 -0700 |
| commit | 3f74407838d61df629e96ad7082db4993d696119 (patch) | |
| tree | 8c5a60dc1804758cee103ec85ac7a69d45993898 | |
| parent | 1760dafbabb12a6486a928c8d5e8a376a2fe5271 (diff) | |
| parent | 8dcdf567311a7f088ab538f41a0e947b825ce75d (diff) | |
| download | PROJ-3f74407838d61df629e96ad7082db4993d696119.tar.gz PROJ-3f74407838d61df629e96ad7082db4993d696119.zip | |
Fix C89 build failure with dphi.
error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
28 files changed, 215 insertions, 170 deletions
diff --git a/configure.ac b/configure.ac index e89961eb..e47e6b46 100644 --- a/configure.ac +++ b/configure.ac @@ -144,7 +144,7 @@ AC_SUBST(THREAD_LIB,$THREAD_LIB) AC_CONFIG_FILES([Makefile cmake/Makefile src/Makefile test/Makefile test/gie/Makefile test/gigs/Makefile man/Makefile man/man1/Makefile man/man3/Makefile nad/Makefile - jniwrap/Makefile jniwrap/org/Makefile jniwrap/org/proj4/Makefile]) + jniwrap/Makefile jniwrap/org.osgeo.proj/Makefile jniwrap/org.osgeo.proj/org/Makefile jniwrap/org.osgeo.proj/org/proj4/Makefile]) AC_CONFIG_FILES([nad/install], [chmod +x nad/install]) AC_CONFIG_FILES([proj.pc]) diff --git a/jniwrap/Makefile.am b/jniwrap/Makefile.am index 4a176362..2d33809a 100644 --- a/jniwrap/Makefile.am +++ b/jniwrap/Makefile.am @@ -1,6 +1,6 @@ EXTRA_DIST = build.xml README.md -SUBDIRS = org +SUBDIRS = org.osgeo.proj install-data-local: echo In jniwrap diff --git a/jniwrap/README.md b/jniwrap/README.md index 20c2c86c..3cce43c0 100644 --- a/jniwrap/README.md +++ b/jniwrap/README.md @@ -1,21 +1,21 @@ -# Proj bridge to Java +# PROJ bridge to Java -This is the third release of JNI wrappers for the main Proj functions. +This is the third release of JNI wrappers for the main PROJ functions. The first release of JNI wrappers were created by http://www.hydrologis.com. The second release of JNI wrappers were created by http://www.geoapi.org. -## What is "Proj bridge to Java" +## What is "PROJ bridge to Java" -_Proj bridge to Java_ is a small library of Java classes that wrap a few Proj functions +_Proj bridge to Java_ is a small library of Java classes that wrap a few PROJ functions by using the Java Native Interface (JNI). The main Java class is `org.proj4.PJ`. ### Compilation -To compile the native part, `configure` has to be run in the Proj directory like this: +To compile the native part, `configure` has to be run in the PROJ directory like this: CFLAGS=-Iinclude2 ./configure --with-jni=include1 @@ -35,7 +35,7 @@ It applies to Linux, MacOS and Windows (and virtually to every system supporting ### Requirements -Beyond the ones already put by Proj, you need: +Beyond the ones already put by PROJ, you need: * For compilation: * Java 9+, the Java standard development kit version 9 or above @@ -70,8 +70,8 @@ Proj.4 license for the second release. ## Usage & a fast example: -The `proj.jar` is all is needed to implement Proj support in java applications. -The whole job is done by the Proj library, so there are just a couple of functions that be used. +The `proj.jar` is all is needed to implement PROJ support in java applications. +The whole job is done by the PROJ library, so there are just a couple of functions that be used. The best way is to see everything through an example. In the following example we create two Coordinate Reference System and transform 3 points. @@ -103,7 +103,7 @@ Of course, real applications would read them from a file or other data source. ### compile the Main code -we assume that Proj was compiled with the right flag to support the bridge to Java +we assume that PROJ was compiled with the right flag to support the bridge to Java Therefore we have a library called `proj.jar`. Thus we compile the `Main.java` with the command: diff --git a/jniwrap/build.xml b/jniwrap/build.xml index 7e95e676..ddd424bd 100644 --- a/jniwrap/build.xml +++ b/jniwrap/build.xml @@ -1,14 +1,14 @@ <?xml version="1.0"?> -<project name="Proj bridge to Java" default="compile" basedir="."> +<project name="PROJ bridge to Java" default="compile" basedir="."> <!-- ******************************************* Set directory paths and versions. ******************************************* --> - <property name="src-java" value="."/> - <property name="src-C" value="../src"/> + <property name="src" value="."/> <property name="out" value="out"/> <property name="classes" value="${out}/classes"/> <property name="javadoc" value="${out}/apidocs"/> + <property name="module" value="org.osgeo.proj"/> <property name="version" value="5.1"/> <!-- ******************************************* @@ -18,14 +18,14 @@ <target name="compile"> <mkdir dir="${out}"/> <mkdir dir="${classes}"/> - <javac srcdir="${src-java}" destdir="${classes}" encoding="UTF-8" nativeheaderdir="${src-C}" + <javac modulesourcepath="${src}" destdir="${classes}" encoding="UTF-8" nativeheaderdir="${src}" createMissingPackageInfoClass = "false" includeAntRuntime = "false" includes = "org/**/*.java"/> - <jar destfile="${out}/proj.jar" basedir="${classes}" level="9" strict="fail"> + <jar destfile="${out}/proj.jar" basedir="${classes}/${module}" level="9" strict="fail"> <manifest> - <attribute name="Implementation-Title" value="Proj bridge to Java"/> + <attribute name="Implementation-Title" value="PROJ bridge to Java"/> <attribute name="Implementation-Version" value="${version}"/> <attribute name="Implementation-Vendor" value="Proj.4 project"/> <attribute name="Implementation-URL" value="http://proj4.org/"/> @@ -37,8 +37,16 @@ Build and create documentation. ********************************************************** --> <target name="javadoc" depends="compile"> - <javadoc sourcepath="${src-java}" classpath="${classes}" destdir="${javadoc}" encoding="UTF-8" - noqualifier="all" windowtitle="Proj bridge to Java" author="false"/> + <javadoc classpath="${classes}/${module}" destdir="${javadoc}" + encoding="UTF-8" noqualifier="all" windowtitle="PROJ bridge to Java" author="false" version="true" + link="http://www.geoapi.org/3.0/javadoc/" additionalparam="-html5"> + <sourcefiles> + <fileset dir="${src}/${module}"> + <include name="org/**/*.java"/> + <exclude name="module-info.java"/> + </fileset> + </sourcefiles> + </javadoc> </target> <!-- ******************************************* diff --git a/jniwrap/org.osgeo.proj/Makefile.am b/jniwrap/org.osgeo.proj/Makefile.am new file mode 100644 index 00000000..6c02a743 --- /dev/null +++ b/jniwrap/org.osgeo.proj/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST = module-info.java + +SUBDIRS = org + diff --git a/jniwrap/org.osgeo.proj/module-info.java b/jniwrap/org.osgeo.proj/module-info.java new file mode 100644 index 00000000..ea8a623a --- /dev/null +++ b/jniwrap/org.osgeo.proj/module-info.java @@ -0,0 +1,29 @@ +/****************************************************************************** + * Project: PROJ.4 + * Purpose: Java/JNI wrappers for PROJ API. + * Author: Martin Desruisseaux + * + ****************************************************************************** + * Copyright (c) 2018, Open Geospatial Consortium, Inc. + * + * 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. + */ +module org.osgeo.proj { + exports org.proj4; +} diff --git a/jniwrap/org/Makefile.am b/jniwrap/org.osgeo.proj/org/Makefile.am index f07adff1..f07adff1 100644 --- a/jniwrap/org/Makefile.am +++ b/jniwrap/org.osgeo.proj/org/Makefile.am diff --git a/jniwrap/org/proj4/Makefile.am b/jniwrap/org.osgeo.proj/org/proj4/Makefile.am index 665fc39d..665fc39d 100644 --- a/jniwrap/org/proj4/Makefile.am +++ b/jniwrap/org.osgeo.proj/org/proj4/Makefile.am diff --git a/jniwrap/org/proj4/PJ.java b/jniwrap/org.osgeo.proj/org/proj4/PJ.java index 6b387287..de09f86a 100644 --- a/jniwrap/org/proj4/PJ.java +++ b/jniwrap/org.osgeo.proj/org/proj4/PJ.java @@ -1,10 +1,10 @@ /****************************************************************************** * Project: PROJ.4 - * Purpose: Java/JNI wrappers for PROJ.4 API. + * Purpose: Java/JNI wrappers for PROJ API. * Author: Martin Desruisseaux * ****************************************************************************** - * Copyright (c) 2011, Open Geospatial Consortium, Inc. + * Copyright (c) 2011-2018, Open Geospatial Consortium, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,58 +23,60 @@ * 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. - ***************************************************************************** - * This file is a copy of a file developed in the GeoAPI "Proj.4 binding" - * module (http://www.geoapi.org/geoapi-proj4/index.html). If this file is - * modified, please consider synchronizing the changes with GeoAPI. + ****************************************************************************** */ package org.proj4; +import java.util.Objects; +import java.lang.annotation.Native; + /** - * Wraps the <a href="http://proj.osgeo.org/">Proj4</a> {@code PJ} native data structure. - * Almost every methods defined in this class are native methods delegating the work to the - * Proj.4 library. This class is the only place where such native methods are defined. - * <p> - * In the Proj.4 library, the {@code PJ} structure aggregates in a single place information usually - * split in many different ISO 19111 interfaces: {@link org.opengis.referencing.datum.Ellipsoid}, + * Wraps the <a href="http://proj4.org/">PROJ</a> {@code PJ} native data structure. + * Almost every methods defined in this class are native methods delegating the work to the PROJ library. + * This class is the only place where such native methods are defined. + * + * <p>In the PROJ library, the {@code PJ} structure aggregates in a single place information usually + * splitted in many different ISO 19111 interfaces: {@link org.opengis.referencing.datum.Ellipsoid}, * {@link org.opengis.referencing.datum.Datum}, {@link org.opengis.referencing.datum.PrimeMeridian}, * {@link org.opengis.referencing.cs.CoordinateSystem}, {@link org.opengis.referencing.crs.CoordinateReferenceSystem} * and their sub-interfaces. The relationship with the GeoAPI methods is indicated in the - * "See" tags when appropriate. + * "See" tags when appropriate.</p> * * @author Martin Desruisseaux (Geomatys) + * @version 5.1 + * @since 4.8 */ public class PJ { /** - * The maximal number of dimension accepted by the {@link #transform(PJ, int, double[], int, int)} - * method. This upper limit is actually somewhat arbitrary. This limit exists mostly as a safety - * against potential misuse. + * The maximal number of dimension accepted by the {@link #transform(PJ, int, double[], int, int)} method. + * This upper limit is actually somewhat arbitrary. This limit exists mostly as a safety against potential misuse. */ + @Native public static final int DIMENSION_MAX = 100; - // IMPLEMENTATION NOTE: if the value is modified, edit also the native C file. /** - * Loads the Proj4 library. + * Loads the PROJ library. */ static { System.loadLibrary("proj"); } /** - * The pointer to {@code PJ} structure allocated in the C/C++ heap. This value has no - * meaning in Java code. <strong>Do not modify</strong>, since this value is used by Proj4. - * Do not rename neither, unless you update accordingly the C code in JNI wrappers. + * The pointer to {@code PJ} structure allocated in the C/C++ heap. This value has no meaning in Java code. + * <strong>Do not modify</strong>, since this value is used by PROJ. Do not rename neither, unless you update + * accordingly the C code in JNI wrappers. */ private final long ptr; /** - * Creates a new {@code PJ} structure from the given Proj4 definition string. + * Creates a new {@code PJ} structure from the given PROJ definition string. * - * @param definition The Proj.4 definition string. - * @throws IllegalArgumentException If the PJ structure can not be created from the given string. + * @param definition the PROJ definition string. + * @throws IllegalArgumentException if the PJ structure can not be created from the given string. */ public PJ(final String definition) throws IllegalArgumentException { + Objects.requireNonNull(definition); ptr = allocatePJ(definition); if (ptr == 0) { throw new IllegalArgumentException(definition); @@ -87,15 +89,12 @@ public class PJ { * {@linkplain org.opengis.referencing.crs.ProjectedCRS#getBaseCRS() base geographic CRS} * from a {@linkplain org.opengis.referencing.crs.ProjectedCRS projected CRS}. * - * @param crs The CRS (usually projected) from which to derive a new CRS. - * @param type The type of the new CRS. Currently, only {@link Type#GEOGRAPHIC} is supported. - * @throws IllegalArgumentException If the PJ structure can not be created. + * @param crs the CRS (usually projected) from which to derive a new CRS. + * @param type the type of the new CRS. Currently, only {@link Type#GEOGRAPHIC} is supported. + * @throws IllegalArgumentException if the PJ structure can not be created. */ public PJ(final PJ crs, final Type type) throws IllegalArgumentException { - if (crs == null) { - // TODO: Use Objects with JDK 7. - throw new NullPointerException("The CRS must be non-null."); - } + Objects.requireNonNull(crs, "The CRS must be non-null."); if (type != Type.GEOGRAPHIC) { throw new IllegalArgumentException("Can not derive the " + type + " type."); } @@ -111,8 +110,8 @@ public class PJ { * to the {@link #ptr} field. The allocated structure is released by the {@link #finalize()} * method. * - * @param definition The Proj4 definition string. - * @return A pointer to the PJ native data structure, or 0 if the operation failed. + * @param definition the PROJ definition string. + * @return a pointer to the PJ native data structure, or 0 if the operation failed. */ private static native long allocatePJ(String definition); @@ -122,39 +121,41 @@ public class PJ { * the return value <strong>must</strong> be assigned to the {@link #ptr} field. * The allocated structure is released by the {@link #finalize()} method. * - * @param projected The CRS from which to derive the base geographic CRS. - * @return A pointer to the PJ native data structure, or 0 if the operation failed. + * @param projected the CRS from which to derive the base geographic CRS. + * @return a pointer to the PJ native data structure, or 0 if the operation failed. */ private static native long allocateGeoPJ(PJ projected); /** - * Returns the version number of the Proj4 library. + * Returns the version number of the PROJ library. * - * @return The Proj.4 release string. + * @return the PROJ release string. */ public static native String getVersion(); /** - * Returns the Proj4 definition string. This is the string given to the constructor, + * Returns the PROJ definition string. This is the string given to the constructor, * expanded with as much information as possible. * - * @return The Proj4 definition string. + * @return the PROJ definition string. */ public native String getDefinition(); /** * Returns the Coordinate Reference System type. * - * @return The CRS type. + * @return the CRS type. */ public native Type getType(); /** * The coordinate reference system (CRS) type returned by {@link PJ#getType()}. - * In the Proj.4 library, a CRS can only be geographic, geocentric or projected, + * In the PROJ library, a CRS can only be geographic, geocentric or projected, * without distinction between 2D and 3D CRS. * * @author Martin Desruisseaux (Geomatys) + * @version 5.1 + * @since 4.8 */ public static enum Type { /* @@ -184,7 +185,7 @@ public class PJ { /** * Returns the value stored in the {@code a_orig} PJ field. * - * @return The axis length stored in {@code a_orig}. + * @return the axis length stored in {@code a_orig}. * * @see org.opengis.referencing.datum.Ellipsoid#getSemiMajorAxis() */ @@ -193,18 +194,18 @@ public class PJ { /** * Returns the value computed from PJ fields by {@code √((a_orig)² × (1 - es_orig))}. * - * @return The axis length computed by {@code √((a_orig)² × (1 - es_orig))}. + * @return the axis length computed by {@code √((a_orig)² × (1 - es_orig))}. * * @see org.opengis.referencing.datum.Ellipsoid#getSemiMinorAxis() */ public native double getSemiMinorAxis(); /** - * Returns the square of the ellipsoid eccentricity (ε²). The eccentricity - * is related to axis length by ε=√(1-(<var>b</var>/<var>a</var>)²). The + * Returns the square of the ellipsoid eccentricity (ε²). The eccentricity + * is related to axis length by ε=√(1-(<var>b</var>/<var>a</var>)²). The * eccentricity of a sphere is zero. * - * @return The eccentricity. + * @return the eccentricity. * * @see org.opengis.referencing.datum.Ellipsoid#isSphere() * @see org.opengis.referencing.datum.Ellipsoid#getInverseFlattening() @@ -213,9 +214,9 @@ public class PJ { /** * Returns an array of character indicating the direction of each axis. Directions are - * characters like {@code 'e'} for East, {@code 'n'} for North and {@code 'u'} for Up. + * characters like {@code 'e'} for East, {@code 'n'} for North and {@code 'u'} for Up. * - * @return The axis directions. + * @return the axis directions. * * @see org.opengis.referencing.cs.CoordinateSystemAxis#getDirection() */ @@ -224,7 +225,7 @@ public class PJ { /** * Longitude of the prime meridian measured from the Greenwich meridian, positive eastward. * - * @return The prime meridian longitude, in degrees. + * @return the prime meridian longitude, in degrees. * * @see org.opengis.referencing.datum.PrimeMeridian#getGreenwichLongitude() */ @@ -235,32 +236,30 @@ public class PJ { * * @param vertical {@code false} for the conversion factor of horizontal axes, * or {@code true} for the conversion factor of the vertical axis. - * @return The conversion factor to metres for the given axis. + * @return the conversion factor to metres for the given axis. */ public native double getLinearUnitToMetre(boolean vertical); /** - * Transforms in-place the coordinates in the given array. The coordinates array shall contain - * (<var>x</var>,<var>y</var>,<var>z</var>,…) tuples, where the <var>z</var> and - * following dimensions are optional. Note that any dimension after the <var>z</var> value - * are ignored. - * <p> - * Input and output units: - * <p> + * Transforms in-place the coordinates in the given array. + * The coordinates array shall contain (<var>x</var>,<var>y</var>,<var>z</var>,…) tuples, + * where the <var>z</var> and any additional dimensions are optional. + * Note that any dimension after the <var>z</var> value are ignored. + * + * <p>Input and output units:</p> * <ul> * <li>Angular units (as in longitude and latitudes) are decimal degrees.</li> * <li>Linear units are usually metres, but this is actually projection-dependent.</li> * </ul> * - * @param target The target CRS. - * @param dimension The dimension of each coordinate value. Must be in the [2-{@value #DIMENSION_MAX}] range. - * @param coordinates The coordinates to transform, as a sequence of - * (<var>x</var>,<var>y</var>,<<var>z</var>>,…) tuples. - * @param offset Offset of the first coordinate in the given array. - * @param numPts Number of points to transform. - * @throws NullPointerException If the {@code target} or {@code coordinates} argument is null. + * @param target the target CRS. + * @param dimension the dimension of each coordinate value. Must be in the [2-{@value #DIMENSION_MAX}] range. + * @param coordinates the coordinates to transform, as a sequence of (<var>x</var>,<var>y</var>,<<var>z</var>>,…) tuples. + * @param offset offset of the first coordinate in the given array. + * @param numPts number of points to transform. + * @throws NullPointerException if the {@code target} or {@code coordinates} argument is null. * @throws IndexOutOfBoundsException if the {@code offset} or {@code numPts} arguments are invalid. - * @throws PJException If the operation failed for an other reason (provided by Proj4). + * @throws PJException if the operation failed for another reason (provided by PROJ). * * @see org.opengis.referencing.operation.MathTransform#transform(double[], int, double[], int, int) */ @@ -270,24 +269,23 @@ public class PJ { /** * Returns a description of the last error that occurred, or {@code null} if none. * - * @return The last error that occurred, or {@code null}. + * @return the last error that occurred, or {@code null}. */ public native String getLastError(); /** * Returns the string representation of the PJ structure. * - * @return The string representation. + * @return the string representation. */ @Override public native String toString(); /** - * Deallocates the native PJ data structure. This method can be invoked only by the garbage - * collector, and must be invoked exactly once (no more, no less). - * <strong>NEVER INVOKE THIS METHOD EXPLICITLY, NEVER OVERRIDE</strong>. + * Deallocates the native PJ data structure. + * This method should be invoked exactly once, only by the garbage collector, */ @Override - @SuppressWarnings("deprecation") + @SuppressWarnings({"deprecation", "FinalizeDeclaration"}) protected final native void finalize(); } diff --git a/jniwrap/org/proj4/PJException.java b/jniwrap/org.osgeo.proj/org/proj4/PJException.java index 18a58851..4b465e6a 100644 --- a/jniwrap/org/proj4/PJException.java +++ b/jniwrap/org.osgeo.proj/org/proj4/PJException.java @@ -1,10 +1,10 @@ /****************************************************************************** * Project: PROJ.4 - * Purpose: Java/JNI wrappers for PROJ.4 API. + * Purpose: Java/JNI wrappers for PROJ API. * Author: Martin Desruisseaux * ****************************************************************************** - * Copyright (c) 2011, Open Geospatial Consortium, Inc. + * Copyright (c) 2011-2018, Open Geospatial Consortium, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,10 +23,7 @@ * 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. - ***************************************************************************** - * This file is a copy of a file developed in the GeoAPI "Proj.4 binding" - * module (http://www.geoapi.org/geoapi-proj4/index.html). If this file is - * modified, please consider synchronizing the changes with GeoAPI. + ****************************************************************************** */ package org.proj4; @@ -35,6 +32,8 @@ package org.proj4; * Exception thrown when a call to {@link PJ#transform(PJ, int, double[], int, int)} failed. * * @author Martin Desruisseaux (Geomatys) + * @version 5.1 + * @since 4.8 */ public class PJException extends Exception { /** @@ -52,7 +51,7 @@ public class PJException extends Exception { /** * Constructs a new exception with the given message. * - * @param message A message that describe the cause for the failure. + * @param message a message that describe the cause for the failure. */ public PJException(final String message) { super(message); diff --git a/jniwrap/org/proj4/package-info.java b/jniwrap/org.osgeo.proj/org/proj4/package-info.java index 8a6b75a3..814d2483 100644 --- a/jniwrap/org/proj4/package-info.java +++ b/jniwrap/org.osgeo.proj/org/proj4/package-info.java @@ -1,10 +1,10 @@ /****************************************************************************** * Project: PROJ.4 - * Purpose: Java/JNI wrappers for PROJ.4 API. + * Purpose: Java/JNI wrappers for PROJ API. * Author: Martin Desruisseaux * ****************************************************************************** - * Copyright (c) 2011, Open Geospatial Consortium, Inc. + * Copyright (c) 2011-2018, Open Geospatial Consortium, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -23,18 +23,17 @@ * 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. - ***************************************************************************** - * This file is a copy of a file developed in the GeoAPI "Proj.4 binding" - * module (http://www.geoapi.org/geoapi-proj4/index.html). If this file is - * modified, please consider synchronizing the changes with GeoAPI. + ****************************************************************************** */ /** - * Wrappers for the <a href="http://proj.osgeo.org/">Proj4</a> library. The {@link org.proj4.PJ} - * class contains only native methods delegating their work to the Proj.4 library. + * Wrappers for the <a href="http://proj4.org/">PROJ</a> library. + * The {@link org.proj4.PJ} class contains only native methods delegating their work to the PROJ library. * For higher-level methods making use of those native methods, see for example the - * <a href="http://www.geoapi.org/geoapi-proj4/index.html">GeoAPI bindings for Proj.4</a>. + * <a href="http://www.geoapi.org/geoapi-proj4/index.html">GeoAPI bindings for PROJ</a>. * * @author Martin Desruisseaux (Geomatys) + * @version 5.1 + * @since 4.8 */ package org.proj4; diff --git a/src/PJ_healpix.c b/src/PJ_healpix.c index f3a9c0f8..c3eae14f 100644 --- a/src/PJ_healpix.c +++ b/src/PJ_healpix.c @@ -526,7 +526,7 @@ static LP s_healpix_inverse(XY xy, PJ *P) { /* sphere */ LP lp; lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; - pj_ctx_set_errno(P->ctx, -15); + pj_ctx_set_errno(P->ctx, PJD_ERR_INVALID_X_OR_Y); return lp; } return healpix_sphere_inverse(xy); @@ -540,7 +540,7 @@ static LP e_healpix_inverse(XY xy, PJ *P) { /* ellipsoid */ 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); + pj_ctx_set_errno(P->ctx, PJD_ERR_INVALID_X_OR_Y); return lp; } lp = healpix_sphere_inverse(xy); @@ -574,7 +574,7 @@ static LP s_rhealpix_inverse(XY xy, PJ *P) { /* sphere */ LP lp; lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; - pj_ctx_set_errno(P->ctx, -15); + pj_ctx_set_errno(P->ctx, PJD_ERR_INVALID_X_OR_Y); return lp; } xy = combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 1); @@ -590,7 +590,7 @@ static LP e_rhealpix_inverse(XY xy, PJ *P) { /* ellipsoid */ 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); + pj_ctx_set_errno(P->ctx, PJD_ERR_INVALID_X_OR_Y); return lp; } xy = combine_caps(xy.x, xy.y, Q->north_square, Q->south_square, 1); diff --git a/src/PJ_tmerc.c b/src/PJ_tmerc.c index bc77e45b..f0f34c93 100644 --- a/src/PJ_tmerc.c +++ b/src/PJ_tmerc.c @@ -38,7 +38,7 @@ static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */ if( lp.lam < -M_HALFPI || lp.lam > M_HALFPI ) { xy.x = HUGE_VAL; xy.y = HUGE_VAL; - pj_ctx_set_errno( P->ctx, -14 ); + pj_ctx_set_errno( P->ctx, PJD_ERR_LAT_OR_LON_EXCEED_LIMIT ); return xy; } @@ -79,7 +79,7 @@ static XY s_forward (LP lp, PJ *P) { /* Spheroidal, forward */ if( lp.lam < -M_HALFPI || lp.lam > M_HALFPI ) { xy.x = HUGE_VAL; xy.y = HUGE_VAL; - pj_ctx_set_errno( P->ctx, -14 ); + pj_ctx_set_errno( P->ctx, PJD_ERR_LAT_OR_LON_EXCEED_LIMIT ); return xy; } diff --git a/src/aasincos.c b/src/aasincos.c index 627ec14e..c3915613 100644 --- a/src/aasincos.c +++ b/src/aasincos.c @@ -9,7 +9,7 @@ aasin(projCtx ctx,double v) { if ((av = fabs(v)) >= 1.) { if (av > ONE_TOL) - pj_ctx_set_errno( ctx, -19 ); + pj_ctx_set_errno( ctx, PJD_ERR_ACOS_ASIN_ARG_TOO_LARGE ); return (v < 0. ? -M_HALFPI : M_HALFPI); } return asin(v); @@ -21,7 +21,7 @@ aacos(projCtx ctx, double v) { if ((av = fabs(v)) >= 1.) { if (av > ONE_TOL) - pj_ctx_set_errno( ctx, -19 ); + pj_ctx_set_errno( ctx, PJD_ERR_ACOS_ASIN_ARG_TOO_LARGE ); return (v < 0. ? M_PI : 0.); } return acos(v); diff --git a/src/biveval.c b/src/biveval.c index c76a34c7..05e83e21 100644 --- a/src/biveval.c +++ b/src/biveval.c @@ -37,7 +37,7 @@ bcheval(projUV in, Tseries *T) { 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; + pj_errno = PJD_ERR_TCHEBY_VAL_OUT_OF_RANGE; } else { /* double evaluation */ w2.u = w.u + w.u; w2.v = w.v + w.v; diff --git a/src/dmstor.c b/src/dmstor.c index 27593cb0..23871a85 100644 --- a/src/dmstor.c +++ b/src/dmstor.c @@ -51,7 +51,7 @@ dmstor_ctx(projCtx ctx, const char *is, char **rs) { n = 2; break; case 'r': case 'R': if (nl) { - pj_ctx_set_errno( ctx, -16 ); + pj_ctx_set_errno( ctx, PJD_ERR_WRONG_FORMAT_DMS_VALUE ); return HUGE_VAL; } ++s; @@ -63,7 +63,7 @@ dmstor_ctx(projCtx ctx, const char *is, char **rs) { continue; } if (n < nl) { - pj_ctx_set_errno( ctx, -16 ); + pj_ctx_set_errno( ctx, PJD_ERR_WRONG_FORMAT_DMS_VALUE ); return HUGE_VAL; } v += tv * vm[n]; diff --git a/src/jniproj.c b/src/jniproj.c index 072fa04c..67aa2478 100644 --- a/src/jniproj.c +++ b/src/jniproj.c @@ -1,6 +1,6 @@ /****************************************************************************** * Project: PROJ.4 - * Purpose: Java/JNI wrappers for PROJ.4 API. + * Purpose: Java/JNI wrappers for PROJ API. * Author: Antonello Andrea * Martin Desruisseaux * @@ -32,7 +32,7 @@ * \file jniproj.c * * \brief - * Functions used by the Java Native Interface (JNI) wrappers of Proj.4 + * Functions used by the Java Native Interface (JNI) wrappers of PROJ. * * * \author Antonello Andrea @@ -54,9 +54,6 @@ #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 @@ -342,7 +339,7 @@ JNIEXPORT jdouble JNICALL Java_org_proj4_PJ_getLinearUnitToMetre * 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 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. @@ -391,9 +388,9 @@ JNIEXPORT void JNICALL Java_org_proj4_PJ_transform 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. */ + if (dimension < 2 || dimension > org_proj4_PJ_DIMENSION_MAX) { /* 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."); + if (c) (*env)->ThrowNew(env, c, "Illegal number of dimensions."); return; } if ((offset < 0) || (numPts < 0) || (offset + dimension*numPts) > (*env)->GetArrayLength(env, coordinates)) { diff --git a/src/nad_init.c b/src/nad_init.c index 571d2569..844dcad2 100644 --- a/src/nad_init.c +++ b/src/nad_init.c @@ -88,7 +88,7 @@ int nad_ctable_load( projCtx ctx, struct CTABLE *ct, PAFile fid ) pj_log( ctx, PJ_LOG_ERROR, "ctable loading failed on fread() - binary incompatible?" ); - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return 0; } @@ -111,7 +111,7 @@ struct CTABLE *nad_ctable_init( projCtx ctx, PAFile fid ) if( ct == NULL || pj_ctx_fread( ctx, ct, sizeof(struct CTABLE), 1, fid ) != 1 ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_dalloc( ct ); return NULL; } @@ -120,7 +120,7 @@ struct CTABLE *nad_ctable_init( projCtx ctx, PAFile fid ) if( ct->lim.lam < 1 || ct->lim.lam > 100000 || ct->lim.phi < 1 || ct->lim.phi > 100000 ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_dalloc( ct ); return NULL; } @@ -167,7 +167,7 @@ int nad_ctable2_load( projCtx ctx, struct CTABLE *ct, PAFile fid ) "ctable2 loading failed on fread() - binary incompatible?\n" ); } - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return 0; } @@ -193,7 +193,7 @@ struct CTABLE *nad_ctable2_init( projCtx ctx, PAFile fid ) if( pj_ctx_fread( ctx, header, sizeof(header), 1, fid ) != 1 ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return NULL; } @@ -206,7 +206,7 @@ struct CTABLE *nad_ctable2_init( projCtx ctx, PAFile fid ) if( strncmp(header,"CTABLE V2",9) != 0 ) { pj_log( ctx, PJ_LOG_ERROR, "ctable2 - wrong header!" ); - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return NULL; } @@ -230,7 +230,7 @@ struct CTABLE *nad_ctable2_init( projCtx ctx, PAFile fid ) if( ct->lim.lam < 1 || ct->lim.lam > 100000 || ct->lim.phi < 1 || ct->lim.phi > 100000 ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_dalloc( ct ); return NULL; } diff --git a/src/pj_datum_set.c b/src/pj_datum_set.c index 374beda2..e527ff84 100644 --- a/src/pj_datum_set.c +++ b/src/pj_datum_set.c @@ -68,7 +68,10 @@ int pj_datum_set(projCtx ctx, paralist *pl, PJ *projdef) /* find the datum definition */ for (i = 0; (s = pj_datums[i].id) && strcmp(name, s) ; ++i) {} - if (!s) { pj_ctx_set_errno(ctx, -9); return 1; } + if (!s) { + pj_ctx_set_errno(ctx, PJD_ERR_UNKNOWN_ELLP_PARAM); + return 1; + } if( pj_datums[i].ellipse_id && strlen(pj_datums[i].ellipse_id) > 0 ) { diff --git a/src/pj_ell_set.c b/src/pj_ell_set.c index 1f9bbd91..fc655289 100644 --- a/src/pj_ell_set.c +++ b/src/pj_ell_set.c @@ -630,7 +630,10 @@ int pj_ell_set (projCtx ctx, paralist *pl, double *a, double *es) { 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; } + if (!s) { + pj_ctx_set_errno( ctx, PJD_ERR_UNKNOWN_ELLP_PARAM); + return 1; + } start->next = pj_mkparam(pj_ellps[i].major); start->next->next = pj_mkparam(pj_ellps[i].ell); } @@ -645,7 +648,7 @@ int pj_ell_set (projCtx ctx, paralist *pl, double *a, double *es) { } else if (pj_param(ctx,pl, "trf").i) { /* recip flattening */ *es = pj_param(ctx,pl, "drf").f; if (*es == 0.0) { - pj_ctx_set_errno( ctx, -10); + pj_ctx_set_errno(ctx, PJD_ERR_REV_FLATTENING_IS_ZERO); goto bomb; } *es = 1./ *es; @@ -676,7 +679,7 @@ int pj_ell_set (projCtx ctx, paralist *pl, double *a, double *es) { *es = 0.; } else if (pj_param(ctx,pl, "bR_h").i) { /* sphere--harmonic mean */ if ( (*a + b) == 0.0) { - pj_ctx_set_errno(ctx, -20); + pj_ctx_set_errno(ctx, PJD_ERR_TOLERANCE_CONDITION); goto bomb; } *a = 2. * *a * b / (*a + b); @@ -687,7 +690,7 @@ int pj_ell_set (projCtx ctx, paralist *pl, double *a, double *es) { 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); + pj_ctx_set_errno(ctx, PJD_ERR_REF_RAD_LARGER_THAN_90); goto bomb; } tmp = 1. - *es * tmp * tmp; @@ -705,10 +708,14 @@ bomb: 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; } + if (*es < 0.) { + pj_ctx_set_errno(ctx, PJD_ERR_ES_LESS_THAN_ZERO); + return 1; + } + if (*a <= 0.) { + pj_ctx_set_errno(ctx, PJD_ERR_MAJOR_AXIS_NOT_GIVEN); + return 1; + } return 0; } #endif diff --git a/src/pj_gauss.c b/src/pj_gauss.c index 4f27ac12..108ac059 100644 --- a/src/pj_gauss.c +++ b/src/pj_gauss.c @@ -92,6 +92,6 @@ LP pj_inv_gauss(projCtx ctx, LP slp, const void *data) { } /* convergence failed */ if (!i) - pj_ctx_set_errno( ctx, -17 ); + pj_ctx_set_errno(ctx, PJD_ERR_NON_CONV_INV_MERI_DIST); return (elp); } diff --git a/src/pj_gridcatalog.c b/src/pj_gridcatalog.c index 8777185b..0498d5b0 100644 --- a/src/pj_gridcatalog.c +++ b/src/pj_gridcatalog.c @@ -139,8 +139,8 @@ int pj_gc_apply_gridshift( PJ *defn, int inverse, &(defn->last_after_date)); if( defn->last_after_grid == NULL ) { - pj_ctx_set_errno( defn->ctx, -38 ); - return -38; + pj_ctx_set_errno( defn->ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); + return PJD_ERR_FAILED_TO_LOAD_GRID; } } gi = defn->last_after_grid; @@ -149,8 +149,8 @@ int pj_gc_apply_gridshift( PJ *defn, int inverse, /* 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; + pj_ctx_set_errno( defn->ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); + return PJD_ERR_FAILED_TO_LOAD_GRID; } output_after = nad_cvt( input, inverse, gi->ct ); @@ -187,8 +187,8 @@ int pj_gc_apply_gridshift( PJ *defn, int inverse, &(defn->last_before_date)); if( defn->last_before_grid == NULL ) { - pj_ctx_set_errno( defn->ctx, -38 ); - return -38; + pj_ctx_set_errno( defn->ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); + return PJD_ERR_FAILED_TO_LOAD_GRID; } } @@ -198,8 +198,8 @@ int pj_gc_apply_gridshift( PJ *defn, int inverse, /* 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; + pj_ctx_set_errno( defn->ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); + return PJD_ERR_FAILED_TO_LOAD_GRID; } output_before = nad_cvt( input, inverse, gi->ct ); diff --git a/src/pj_gridinfo.c b/src/pj_gridinfo.c index 19113fca..442b3fe6 100644 --- a/src/pj_gridinfo.c +++ b/src/pj_gridinfo.c @@ -146,7 +146,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) if( fid == NULL ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); return 0; } @@ -173,7 +173,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) if( fid == NULL ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); return 0; } @@ -205,7 +205,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) if( fid == NULL ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); return 0; } @@ -235,7 +235,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) { pj_dalloc( row_buf ); pj_dalloc( ct_tmp.cvs ); - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); return 0; } @@ -286,7 +286,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) if( fid == NULL ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); return 0; } @@ -316,7 +316,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) { pj_dalloc( row_buf ); pj_dalloc( ct_tmp.cvs ); - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); return 0; } @@ -361,7 +361,7 @@ int pj_gridinfo_load( projCtx ctx, PJ_GRIDINFO *gi ) if( fid == NULL ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); pj_release_lock(); return 0; } @@ -445,7 +445,7 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist ) /* -------------------------------------------------------------------- */ if( pj_ctx_fread( ctx, header, sizeof(header), 1, fid ) != 1 ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return 0; } @@ -488,13 +488,13 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist ) /* -------------------------------------------------------------------- */ if( pj_ctx_fread( ctx, header, sizeof(header), 1, fid ) != 1 ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return 0; } if( strncmp((const char *) header,"SUB_NAME",8) != 0 ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return 0; } @@ -555,7 +555,7 @@ static int pj_gridinfo_init_ntv2( projCtx ctx, PAFile fid, PJ_GRIDINFO *gilist ) gs_count, ct->lim.lam, ct->lim.phi, ct->lim.lam * ct->lim.phi ); pj_dalloc(ct); - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return 0; } @@ -670,7 +670,7 @@ static int pj_gridinfo_init_ntv1( projCtx ctx, PAFile fid, PJ_GRIDINFO *gi ) /* -------------------------------------------------------------------- */ if( pj_ctx_fread( ctx, header, sizeof(header), 1, fid ) != 1 ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return 0; } @@ -692,7 +692,7 @@ static int pj_gridinfo_init_ntv1( projCtx ctx, PAFile fid, PJ_GRIDINFO *gi ) { pj_log( ctx, PJ_LOG_ERROR, "NTv1 grid shift file has wrong record count, corrupt?" ); - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return 0; } @@ -757,7 +757,7 @@ static int pj_gridinfo_init_gtx( projCtx ctx, PAFile fid, PJ_GRIDINFO *gi ) /* -------------------------------------------------------------------- */ if( pj_ctx_fread( ctx, header, sizeof(header), 1, fid ) != 1 ) { - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return 0; } @@ -783,7 +783,7 @@ static int pj_gridinfo_init_gtx( projCtx ctx, PAFile fid, PJ_GRIDINFO *gi ) { pj_log( ctx, PJ_LOG_ERROR, "gtx file header has invalid extents, corrupt?"); - pj_ctx_set_errno( ctx, -38 ); + pj_ctx_set_errno( ctx, PJD_ERR_FAILED_TO_LOAD_GRID ); return 0; } diff --git a/src/pj_mlfn.c b/src/pj_mlfn.c index dc8aa2fc..24e7b63a 100644 --- a/src/pj_mlfn.c +++ b/src/pj_mlfn.c @@ -56,6 +56,6 @@ pj_inv_mlfn(projCtx ctx, double arg, double es, double *en) { if (fabs(t) < EPS) return phi; } - pj_ctx_set_errno( ctx, -17 ); + pj_ctx_set_errno( ctx, PJD_ERR_NON_CONV_INV_MERI_DIST ); return phi; } diff --git a/src/pj_phi2.c b/src/pj_phi2.c index 5f73d510..b55d9690 100644 --- a/src/pj_phi2.c +++ b/src/pj_phi2.c @@ -14,8 +14,9 @@ double pj_phi2(projCtx ctx, double ts, double e) { int i = N_ITER; for(;;) { + double dphi; con = e * sin(Phi); - double dphi = M_HALFPI - 2. * atan(ts * pow((1. - con) / + dphi = M_HALFPI - 2. * atan(ts * pow((1. - con) / (1. + con), eccnth)) - Phi; Phi += dphi; diff --git a/src/pj_transform.c b/src/pj_transform.c index aaa8c1e4..168711ba 100644 --- a/src/pj_transform.c +++ b/src/pj_transform.c @@ -597,7 +597,7 @@ int pj_geodetic_to_geocentric( double a, double es, if( pj_Convert_Geodetic_To_Geocentric( &gi, y[io], x[io], z[io], x+io, y+io, z+io ) != 0 ) { - ret_errno = -14; + ret_errno = PJD_ERR_LAT_OR_LON_EXCEED_LIMIT; x[io] = y[io] = HUGE_VAL; /* but keep processing points! */ } diff --git a/src/pj_utils.c b/src/pj_utils.c index d2037032..5a1faf72 100644 --- a/src/pj_utils.c +++ b/src/pj_utils.c @@ -113,7 +113,7 @@ PJ *pj_latlong_from_proj( PJ *pj_in ) } else { - pj_ctx_set_errno( pj_in->ctx, -13 ); + pj_ctx_set_errno( pj_in->ctx, PJD_ERR_MAJOR_AXIS_NOT_GIVEN ); return NULL; } diff --git a/src/proj_mdist.c b/src/proj_mdist.c index 4ab50ee9..02d9ebee 100644 --- a/src/proj_mdist.c +++ b/src/proj_mdist.c @@ -117,6 +117,6 @@ proj_inv_mdist(projCtx ctx, double dist, const void *data) { return phi; } /* convergence failed */ - pj_ctx_set_errno(ctx, -17); + pj_ctx_set_errno(ctx, PJD_ERR_NON_CONV_INV_MERI_DIST); return phi; } |
