Class GCTP

java.lang.Object
noaa.coastwatch.util.GCTP
All Implemented Interfaces:
ProjectionConstants, SpheroidConstants

public class GCTP extends Object implements SpheroidConstants, ProjectionConstants
The static routines in the General Cartographic Transformations Package (GCTP) class handle the transformation of data coordinates between common earth projection systems. The class is simply a Java wrapper for the GCTP package in C. See the GCTPC package documentation for full documentation on routine parameters and usage. The native methods of GCTP are no longer supported. Use the MapProjectionFactory to create and work with map projections. The GCTP parameter related methods in this class are still useful for creating arrays of valid parameters to pass to the map projection factory creation methods.
Since:
3.1.0
Author:
Mark Robinson
  • Field Details

    • RADIAN

      public static final int RADIAN
      Radians units code.
      See Also:
    • FEET

      public static final int FEET
      US Feet units code.
      See Also:
    • METER

      public static final int METER
      Meters units code.
      See Also:
    • SECOND

      public static final int SECOND
      Arc Seconds units code.
      See Also:
    • DEGREE

      public static final int DEGREE
      Decimal degrees units code.
      See Also:
    • INT_FEET

      public static final int INT_FEET
      International Feet units code.
      See Also:
    • STPLN_TABLE

      public static final int STPLN_TABLE
      State Plane table units code. The STPLN_TABLE unit value is specifically used for State Plane -- if units equals STPLN_TABLE and Datum is NAD83 -- actual units are retrieved from a table according to the zone. If Datum is NAD27 -- actual units will be feet. An error will occur with this unit if the projection is not State Plane.
      See Also:
    • TERM

      public static final int TERM
      Print errors to the terminal.
      See Also:
    • FILE

      public static final int FILE
      Print errors to a file.
      See Also:
    • BOTH

      public static final int BOTH
      Print errors to both file and terminal.
      See Also:
    • NEITHER

      public static final int NEITHER
      Do not print error messages.
      See Also:
  • Method Details

    • isSupportedSpheroid

      public static boolean isSupportedSpheroid(int spheroid, int system)
      Determines if the projection system supports the specified spheroid earth model. This is the preferred method now over supportsSpheroid(int) because it gives more specific information about spheroids supported. This routine should be used prior to creating a map projection with the MapProjectionFactory methods, to make sure that no error with be thrown if an incompatible projection system and spheroid model are attempted.
      Parameters:
      spheroid - the spheroid to check for support.
      system - the projection system to check for support.
      Returns:
      true if the projection system supports the specified spheroid, or false if not.
    • supportsSpheroid

      public static boolean supportsSpheroid(int system)
      Determines if the projection system supports a generic spheroid earth model, or only a perfect sphere.
      Parameters:
      system - the projection system code.
      Returns:
      true if the projection system supports a generic spheroid, or false if not.
    • getRequirements

      public static GCTP.Requirements[] getRequirements(int system)
      Gets the requirements for the specified projection.
      Parameters:
      system - the projection system code.
      Returns:
      the parameter requirements or null if the projection system is invalid. Generally the requirements array only contains one element. If there is more than one way to specify parameters for the projection system, the array will contain each set of requirements.
    • gctp

      @Deprecated public static double[] gctp(double[] input_coord, int input_system, int input_zone, double[] input_parameters, int input_units, int input_spheroid, int error_message_flag, String error_file, int jpr, String pfile, int output_system, int output_zone, double[] output_parameters, int output_unit, int output_spheroid, String NAD1927_zonefile, String NAD1983_zonefile)
      Deprecated.
      The native methods of GCTP are no longer supported. Use the MapProjectionFactory to create and work with map projections.
      Performs a single coordinate transform. Both input and output coordinate parameters are specified.
      Parameters:
      input_coord - the data coordinate to transform. Input coordinate values are either [x, y] in a projection coordinate system or [lon, lat] for geographic coordinates.
      input_system - the projection type of the input coordinates. The projection type must be a valid GCTP projection code constant.
      input_zone - the zone of the input coordinates if the input system is State Plane or UTM.
      input_parameters - an array of 15 parameters for the input projection system.
      input_units - the input coordinate units. The input units must be a valid GCTP units code constant.
      input_spheroid - the input coordinate spheroid. The input spheroid must be a valid GCTP spheroid code constant.
      error_message_flag - a flag to determine the destination of error messages. The value must be TERM, FILE, BOTH, or NEITHER. See the GCTP constants for details.
      error_file - the file name for error messages.
      jpr - a flag to determine the destination of projection parameter messages. The value must be TERM, FILE, BOTH, or NEITHER. See the GCTP constants for details.
      pfile - the file name for projection parameter messages.
      output_system - the projection type of the output coordinates. The projection type must be a valid GCTP projection code constant.
      output_zone - the zone of the output coordinates if the output system is State Plane or UTM.
      output_parameters - an array of 15 parameters for the output projection system.
      output_unit - the output coordinate units. The output units must be a valid GCTP units code constant.
      output_spheroid - the output coordinate spheroid. The output spheroid must be a valid GCTP spheroid code constant.
      NAD1927_zonefile - the file containing NAD 1927 State Plane zone parameters.
      NAD1983_zonefile - the file containing NAD 1983 State Plane zone parameters.
      Returns:
      the transformed output coordinates. Coordinates are either [x, y] in a projection coordinate system or [lon, lat] for geographic coordinates.
    • init_forward

      @Deprecated public static void init_forward(int output_system, int output_zone, double[] output_parameters, int output_spheroid, String NAD1927_zonefile, String NAD1983_zonefile)
      Deprecated.
      The native methods of GCTP are no longer supported. Use the MapProjectionFactory to create and work with map projections.

      Initializes the forward transformation projection parameters. Subsequent calls to forward will use the specified projection parameters.

      Refer to the gctp(double[], int, int, double[], int, int, int, java.lang.String, int, java.lang.String, int, int, double[], int, int, java.lang.String, java.lang.String) routine output parameters for details.

    • init_inverse

      @Deprecated public static void init_inverse(int input_system, int input_zone, double[] input_parameters, int input_spheroid, String NAD1927_zonefile, String NAD1983_zonefile)
      Deprecated.
      The native methods of GCTP are no longer supported. Use the MapProjectionFactory to create and work with map projections.

      Initializes the inverse transformation projection parameters. Subsequent calls to inverse will use the specified projection parameters.

      Refer to the gctp(double[], int, int, double[], int, int, int, java.lang.String, int, java.lang.String, int, int, double[], int, int, java.lang.String, java.lang.String) routine input parameters for details.

    • forward

      @Deprecated public static double[] forward(double[] pos, int output_system) throws Exception
      Deprecated.
      The native methods of GCTP are no longer supported. Use the MapProjectionFactory to create and work with map projections.
      Transforms coordinates from geographic to projection system.
      Parameters:
      pos - the coordinates to transform as [lon, lat] in radians.
      output_system - the projection type of the output coordinates. The projection type must be a valid GCTP projection code constant.
      Returns:
      the transformed output coordinates as [x, y].
      Throws:
      Exception - if the forward transform failed. Usually, this is because some geographic coordinates have no valid map coordinates.
      See Also:
    • inverse

      @Deprecated public static double[] inverse(double[] pos, int input_system) throws Exception
      Deprecated.
      The native methods of GCTP are no longer supported. Use the MapProjectionFactory to create and work with map projections.
      Transforms coordinates from projection system to geographic.
      Parameters:
      pos - the coordinates to transform in [x, y].
      input_system - the projection type of the input coordinates. The projection type must be a valid GCTP projection code constant.
      Returns:
      the transformed output coordinates as [lon, lat] in radians.
      Throws:
      Exception - if the inverse transform failed.
      See Also:
    • pack_angle

      public static double pack_angle(double angle)
      Packs an angle in degrees to DDDMMMSSS.SS format.
      Parameters:
      angle - the angle in degrees.
      Returns:
      the packed angle in DDDMMMSSS.SS format.
    • unpack_angle

      public static double unpack_angle(double angle)
      Unpacks an angle in DDDMMMSSS.SS format to degrees.
      Parameters:
      angle - the packed angle in DDDMMMSSS.SS format.
      Returns:
      the angle in degrees.
    • main

      public static void main(String[] argv) throws Exception
      Tests this class.
      Parameters:
      argv - the array of command line parameters.
      Throws:
      Exception