C API Users' Guide

SRM SDK Release 4.0.0

July 16, 2004

  1. Introduction
  2. SRM Concepts
  3. SRM Capability
  4. Conversion Types
  5. Typical Usages
  6. Sample Application

Introduction

Spatial information processing requires a robust capability to describe geometric properties such as position, direction and distance. Information may be spatially referenced to local structures (Example: building interiors) and regions (Example: cities), or spatially referenced to the Earth as a whole (Example: global weather). Information may be spatially referenced to other celestial bodies (Examples: astronomical, orbital, and geomagnetic observations). Information may also be spatially referenced to objects defined within contexts such as virtual realities (Example: 3D models). In each of these cases, a spatial reference frame is defined, with respect to which the values of geometric properties may be determined.

It is often necessary to represent position in several different spatial reference frames, simultaneously, according to the context in which the position is to be used. Each spatial reference frame corresponds to a particular way of expressing position. Spatial reference frames may be relative to moving objects (Examples: planets and spacecraft), and therefore have values that are a function of time. It is necessary to specify the time to which the spatial position refers, and the time for which the spatial reference frame is defined.

The Spatial Reference Model (SRM) defines the conceptual model and the methodologies that allow the description, and transformation or conversion, of geometric properties within or among spatial reference frames. The Spatial Reference Model (SRM) supports unambiguous specification of the positions, directions, distances, and times associated with spatial information. It also defines algorithms for precise transformation of positions, directions and distances among different spatial reference frames.

SRM Concepts

This section explains several key concepts as related to the SRM.

Spatial Reference Frame

A spatial reference frame is a spatial coordinate system for a region of the space of an object formed by the binding of an abstract coordinate system (CS) to the linear embedding specified by an Object Reference Model (ORM). A full specification includes values for the CS parameters and a specification of the region of the space of the object. In some cases, some the CS parameters are bound by ORM parameters. In particular, a CS based on an oblate spheroid (or sphere) must match the parameters of the oblate spheroid (or sphere) RD of the ORM.

A spatial reference frame template is the basis for realizing spatial reference frames that share the same CS, similar ORMs, and the same structure in the binding of CS parameter values. Spatial reference frames may be organized into specified sets so as to form an atlas for a large region of space. SRM specifies a collection of spatial reference frame templates (SRFT), realizations of those templates (Standard SRF), and sets of those realizations (SRFS).

SRM defined the following SRF Templates:

  1. Celestiocentric (CC)
  2. Local Space Rectangular 3D (LSR_3D)
  3. Celestiodetic (CD)
  4. Planetodetic (PD)
  5. Local Tangent Space Euclidean (LTSE)
  6. Local Tangent Space Azimuthal Spherical (LTSAS)
  7. Local Tangent Space Cylindrical (LTSC)
  8. Celestiomagnetic (CM)
  9. Equatorial Inertial (EI)
  10. Solar Ecliptic (SEC)
  11. Solar Equatorial (SEQ)
  12. Solar Magnetic Ecliptic (SME)
  13. Solar Magnetic Dipole (SMD)
  14. Heliospheric Aries Ecliptic (HAEC)
  15. Heliospheric Earth Ecliptic (HEEC)
  16. Heliospheric Earth Equatorial (HEEQ)
  17. Mercator (M)
  18. Oblique Mercator Spherical (OMS)
  19. Transverse Mercator (TM)
  20. Lambert Conformal Conic (LCC)
  21. Polar Stereographic (PS)
  22. Equidistant Cylindrical (EC)
  23. Local Space Rectangular 2D (LSR_2D)
  24. Local Space Azimuthal (AZ)
  25. Local Space Polar (Polar )

SRM defined the following SRF Sets:

  1. Alabama State Plane Coordinate System (SPCS)
  2. Geo Tile Reference System Global Coordinate System (GTRS GCS)
  3. Japan Rectangular Plane CS
  4. Lambert NTF
  5. Universal Polar Stereographic (UPS)
  6. Universal Transverse Mercator (UTM)
  7. Wisconsin State Plane Coordinate System (SPCS)

SRM defined the following Standard SRFs:

  1. British National Grid (BNG)
  2. Delaware State Plane Coordinate System (SPCS) 1983
  3. Geocentric Datum Australia 1994
  4. Geocentric WGS 1984
  5. Geodetic Australia 1984
  6. Geodetic WGS 1984
  7. Geodetic Europe 1950
  8. Geodetic North America 1983
  9. Geodetic WGS 1984
  10. Irish Grid 1965
  11. Irish Transverse Mercator 1989
  12. Lambert 1993
  13. Lambert II Wide
  14. Mars Planetocentric 2000
  15. Mars Planetographic 2000
  16. Maryland State Plane Coordinate System (SPCS) 1983

Object Reference Model

A normal embedding of position-space establishes a basis for modeling that object-space with spatial coordinates. Reference Datums (RDs) bound with properly constrained geometric constructs in object-space can determine a unique normal embedding and consequently a model of the object-space, called an object reference model.

Examples of ORMs are: World Geodesic System 1984 (WGS 1894), COAMPS, and Heliocentric Arieas Ecliptic.

HSR

If a spatial object S exists in the space of another spatial object R, and if ORMR is the reference ORM for object R, and if the two objects are fixed with respect to each other, then HSR shall denote a reference transformation from the embedding of ORMS to the embedding of ORMR.

Reference Datum

A reference datum (RD) is a geometric construct in position-space that is used to specify an aspect of an embedding of position-space into object-space. In SRM, reference datums are defined for 1D, 2D, and 3D position-space.

Coordinate Systems

Coordinate systems (CSs) are used to identify positions. Each coordinate system has a type and other properties. Abstract coordinate systems are defined for positions in abstract Euclidean space.

Coordinate

A Coordinate is an element of the coordinate system domain. In particular, if the domain is a subset of 3D Euclidean space (R3), each coordinate is called a 3D coordinate. If the domain is a subset of 2D Euclidean space (R2), each coordinate is called a 2D coordinate. Surface coordinates are defined as the projection of the 3D coordinate onto the surface of a RD.

Examples of coordinates are: Celestiocentric 3D coordinate, Local Space Rectangular 2D coordinate, and Transverse Mercator surface coordinate.

SRM Capability

The SRM API supports the following functionality:

  1. Memory allocation and handling
    1. SRFs
      1. SRF templates (e.g., LSR 3D, TM, Celestiodetic, Celestiocentric)
      2. SRF set members (e.g., UTM zone 12 Southern Hemisphere, GTRS cell 1234, UPS Northern Pole)
      3. Predefined SRFs (e.g., British National Grid)
    2. Coordinates
      1. 2D coordinates
      2. 3D coordinates
      3. Surface coordinates
    3. Directions
    4. Orientations
  2. Conversion
    1. Coordinate conversion between SRFs
    2. Direction conversion between SRFs
    3. Orientation conversion between SRFs
  3. Validation
    1. Coordinate validation within a SRF
    2. Direction validation within a SRF
    3. Orientation validation within a SRF
  4. Calculations
    1. Euclidean distance
    2. Geodesic distance
    3. Point scale
    4. Vertical separation offset
    5. Convergence of the Meridian
    6. Map azimuth
    7. Natural Extent (zone)
  5. Abstract space coordinate instancing in a SRF
Note that SRM version 4.0.0 supports all functionality in (1), (2), (3), (4.a) and (4.g) for most of the commonly used SRF templates. The remaining SRF templates and functionality in (4) and (5) will be supported in subsequent releases.

Conversion Types

There are three types of coordinate conversions:
  1. Direct

    These are conversions that have an algorithm implemented between the source SRF and the target SRF. For instance, the coordinate conversion from a Celestiodetic SRF to a Celestiocentric SRF is a direct conversion. This type of conversion does not involve intermediate SRFs for its computation and thus they are most efficient.

  2. Indirect (a.k.a."chained" or "transitive")

    These conversions are chains of direct conversions, converting first from the source SRF to intermediate SRFs, then to the target SRF. Consequently, these conversions typically take more time to be executed. For instance, the coordinate conversion from a Transverse Mercator SRF to a Celestiocentric SRF is an indirect conversion going through an intermediary conversion to Celestiodetic SRF.

  3. Reflexive

    Reflexive conversions are the cases where the source and the target SRFs are of the same type. The trivial case of this type of conversion is when the source and the target SRFs have the exact same parameter values. In that case, the identity transformation is applied to the source coordinate. Another example, to convert from a CD SRF to another CD SRF with a different ORM/HSR pair. In that case, a datum shift is performed by converting the coordinate from the source CD SRF to an intermediate CC SRF, apply the datum shift and then to the target CD SRF.

The type of conversions applied to the coordinates is transparent to the users. The users can invoke the SRM_ChangeCoordinateSRF() method, regardless of whether the conversion is direct, indirect, or reflexive. The API will perform the conversion in a most efficient way. If a conversion is not supported between the two given SRFs, then the call to SRM_ChangeCoordinateSRF() will return the proper status code.

The chart below is provided as a reference to indicate which coordinate conversions are supported in SRM Version 4.0.0. Empty cells indicate conversion not supported in 4.0.0.

I
AZ CC CD CM EC EI HAEC HEEC HEEQ LCC LSR_2D LSR_3 LTSAS LTSC LTSE M OM PD Polar PS SEC SEQ SME SMD TM
AZ . . . . . . . . . . . . . . . . . . . . . . . . .
CC . R D . I . D D D I . . I I D I I D . I . . . . I
CD . D R . D . I I I D . . I I I D D R . D . . . . D
CM . . . . . . . . . . . . . . . . . . . . . . . . .
EC . I D . R . I I I I . . I I I I D I . I . . . . I
EI . . . . . . . . . . . . . . . . . . . . . . . . .
HAEC . D I . I . R . . I . . I I I I I I . I . . . . I
HEEC . D I . I . . R . I . . I I I I I I . I . . . . I
HEEQ . D I . I . . . R I . . I I I I I I . I . . . . I
LCC . I D . I . I I I R . . I I I I I D . I . . . . I
LSR_2D . . . . . . . . . . R . . . . . . . . . . . . . .
LSR_3D . . . . . . . . . . . R . . . . . . . . . . . . .
LTSAS . I I . I . I I I I . . R . D I I I . I . . . . I
LTSC . I I . I . I I I I . . . R D I I I . I . . . . I
LTSE . D I . I . I I I I . . D D R I I I . I . . . . I
M . I D . I . I I I I . . I I I R I D . I . . . . I
OM . I D . I . I I I I . . I I I I R D . I . . . . I
PD . D R . D . I I I D . . I I I D D R . D . . . . D
Polar . . . . . . . . . . . . . . . . . . . . . . . . .
PS . I D . I . I I I I . . I I I I I D . R . . . . I
SEC . . . . . . . . . . . . . . . . . . . . . . . . .
SEQ . . . . . . . . . . . . . . . . . . . . . . . . .
SME . . . . . . . . . . . . . . . . . . . . . . . . .
SMD . . . . . . . . . . . . . . . . . . . . . . . . .
TM . I D . I . I I I I . . I I I I I D . I . . . . R

Typical Usages

A few typical API usages are described in this section

Convert a coordinate from one SRF to another

In order to convert a coordinate from one SRF to another, the user has to:
  1. Allocate the SRF to which the coordinate to be converted is associated (source).
  2. Allocate the SRF to which the resulting converted coordinate is associate (target).
  3. Allocate the source coordinate.
  4. Allocate the target coordinate with default values.
  5. Compute the target coordinate.
The users should re-use the allocated SRFs for the coordinate conversions to minimize the one-time initialization cost. The source and target coordinates must be both 2D, 3D, or surface.

The details on how to allocate SRFs, allocate coordinates and convert coordinates are as follows:

  1. Allocate a SRF

    There are three ways to allocate SRFs depending whether they are instances of SRF Templates, SRF Sets, or standard SRFs. Once a SRF is allocated, its parameter values cannot be changed:

    1. Allocate a SRF Template:

      There are 25 SRF Template types in SRM. These include SRF_Celestiodetic, SRF_Celestiocentric, SRF_LocalSpaceRectangular3D, and Transverse Mercator. Use specific SRM_CreateSRF_XX functions to allocate these types of SRF. For example, to allocate a Celestiodetic SRF using the WGS 1984 ORM with the Identity HSR transformation:

      SRM_SRF cd_srf;
      SRM_Status_Code status;
      SRM_ORM_Parameters cd_params;
      cd_params.orm_code = SRM_ORM_WGS_1984;
      cd_params.hsr_code = SRM_HSR_WGS_1984_IDENTITY;
      status = SRM_CreateSRF_CD( cd_params, &cd_srf );
      	
    2. Allocate a SRF Set member:

      There are 7 SRF Sets currently defined in SRM. These include Universal Transverse Mercator (UTM), Geo Tile Reference System (GRTS) Global Coordinate System (GCS), and Universal Polar Stereographic (UPS). Each of these SRF Sets are composed of a well-defined set of members. For example, UTM is composed of 120 members (zones) while GTRS GCS has 59,896 members (cell ids). These SRF Set members can be allocated by invoking the SRM_CreateSRFSetMember function with proper SRM SET Code and member code. For example, to allocate an UTM member zone 12 in North hemisphere using the WGS 1984 ORM with the Identity HSR transformation:

      SRM_SRF utm12_srf;
      SRM_Status_Code status;
      SRM_ORM_Parameters utm_params;
      cd_params.orm_code = SRM_ORM_WGS_1984;
      cd_params.hsr_code = SRM_HSR_WGS_1984_IDENTITY;
      status = SRM_CreateSRFSetMember( SRM_SRFS_UNIVERSAL_TRANSVERSE_MERCATOR, 
                                       SRM_SSM_UTM_ZONE_12_NORTHERN_HEMISPHERE,
                                       utm_params,
                                       &utm12_srf );
                  
      The SRF template type for the Universal Transverse Mercator SRF is intrinsically Transverse Mercator. In other words, the allocated UTM SRF is an instance of the Transverse Mercator SRF Template, and therefore, supports all the function applicable to that SRF Template. Likewise, for example, a GTRS GCS SRF is intrinsically an instance of the Local Tangent Space Euclidean SRF Template.

    3. Allocate a Standard SRF:

      There are 15 Standard SRFs currently defined in SRM. These include British National Grid (BNG), Irish Grid, and the Maryland State Plane Coordinate System (SPCS). Instances of these Standard SRFs can be allocated by invoking the SRM_CreateStandardSRF() function using the proper SRF code. For example, to allocate an instance of BNG:

      SRM_SRF bng_srf;
      SRM_Status_Code status;
      status = SRM_CreateStandardSRF( SRM_SRF_BRITISH_NATIONAL_GRID,
                                      &bng_srf );
                  
      The SRF template type for the British National Grid SRF is intrinsically Transverse Mercator. In other words, the allocated BNG SRF is an instance of the Transverse Mercator SRF Template, and therefore, supports all the functions applicable to that SRF Template. Likewise, for example, a Maryland SPCS SRF is intrinsically an instance of the Lambert Conformal Conic SRF Template.

      There are no SRF parameter arguments for the creation of Standard SRFs because these SRFs have all their parameters pre-defined.

  2. Allocate a Coordinate

    Each SRF Template has its specific coordinates defined. The coordinates is only valid when associated with a specific SRF. Depending on the SRF allocated, 2D, 3D or surface coordinates can be associated with it. Use the SRM_CreateCoordinateXX_YY function to allocate the coordinates, where "XX" is related to the SRF template and the YY is either 2D, 3D or Surface coordinate:

    For example, to allocate a 3D coordinate for a Celestiodetic SRF:

    SRM_Status_Code status;
    SRM_Coordinate cd_3d_coord;
    SRM_CD_3D_Coordinate cd_3d_comp;
    cd_3d_comp.latitude = 0.8987;
    cd_3d_comp.longitude = 0.5645;
    cd_3d_comp.ellipsoidal_height = 1000.0;
    status = SRM_CreateCoordinateCD_3D( cd_srf,  cd_3d_comp, &cd_3d_coord );
                 
    Another example, to allocate a UTM surface coordinate for a UTM SRF:

    SRM_Status_Code status;
    SRM_Coordinate utm_surf_coord;
    SRM_Map_Projection_Surface_Coordinate utm_surf_comp;
    utm_surf_comp.easting = 550.0;
    utm_surf_comp.northing = 320.0;
    status = SRM_CreateCoordinateMap_Projection_Surface ( utm12_srf, utm_surf_comp, &utm_surf_coord );
                 
  3. Convert a source coordinate from a source SRF to a target SRF

    Having allocated the source SRF, the source coordinate, the target SRF, and the target coordinate, invoke the SRM_ChangeCoordinateSRF() to calculate the target coordinate and the Valid Region. For example, to convert a Celestiodetic 3D coordinate to a Transverse Mercator SRF:

    status = SRM_ChangeCoordinateSRF( cd_srf, cd_3d_coord, utm12_srf, &utm12_3d_coord, &valid_region );
             

Convert a direction from one SRF to another

The steps to convert a direction (source direction) from its original SRF (source SRF) to another SRF (target SRF) resulting in the final direction (target direction) is similar to converting a coordinate as follows:

  1. Allocate a SRF (same as above).
  2. Allocate a reference location coordinate (same as above). The restriction is that this coordinate must be a 3D coordinate.
  3. Allocate a Direction

    A Direction object can be allocated using the SRM_CreateDirection() function. For example, to allocate a Direction using a Celestiodetic 3D coordinate "cd_ref_location" associated with and a direction vector (1.0, 2.0, 3.0):

    SRM_Status_Code status;
    Direction cd_dir;
    SRM_Long_Float vector[3] = { 1.0, 2.0, 3.0 };
    status = SRM_CreateDirection( cd_srf, cd_ref_location, vector, &cd_dir );
            
    The Celectiodetic SRF "cd_srf" must be the same one associated with both the reference location "cd_ref_location" and the direction object "cd_dir".

  4. Convert a source Direction from the source SRF to a target SRF

    Having allocated the source and target SRFs and Directions, invoke the SRM_ChangeDirectionSRF() function to calculate the target direction and the Valid Region. For example, to convert the Celestiodetic direction to a Transverse Mercator SRF "tm_srf":

    SRM_Status_Code status;
    status = SRM_ChangeDirectionSRF( cd_srf, cd_dir, tm_srf, &tm_dir, &valid_region);
             
    In converting a Direction, both its reference location and the vector are converted to the target SRF. The valid region is associated with the resulting reference location.

Convert an orientation from one SRF to another

The steps to convert a orientation (source orientation) from its original SRF (source SRF) to another SRF (target SRF) resulting in the final orientation (target direction) is similar to converting a direction as follows:

  1. Allocate a SRF (same as above).
  2. Allocate a reference location coordinate (same as above). The restriction is that this coordinate must be a 3D coordinate.
  3. Allocate an orientation

    An Orientation object can be allocated using the SRM_CreateOrientation() function. For example, to allocate a Direction using a Celestiodetic 3D coordinate "cd_ref_location" associated with and an identity matrix:

    SRM_Status_Code status;
    Orientation cd_ori;
    SRM_Long_Float ident_mat[3][3] = { {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0} };
    status = SRM_CreateOrientation( cd_srf, cd_ref_location, ident_mat, &cd_ori );
            
    The Celestiodetic SRF "cd_srf" must be the same one associated with both the reference location "cd_ref_location" and the direction object "cd_ori".

  4. Convert a source orientation from the source SRF to a target SRF

    Having allocated the source and target SRFs and orientations, invoke the SRM_ChangeOrientationSRF() function to calculate the target orientation and the Valid Region. For example, to convert the Celestiodetic orientation to a Transverse Mercator SRF "tm_srf":

    SRM_Status_Code status;
    status = SRM_ChangeOrientationSRF( cd_Srf, cd_ori, tm_srf, &tm_ori, &valid_region);
             
    In converting an Orientation, both its reference location and the matrix are converted to the target SRF. The valid region is associated with the resulting reference location.

Sample Application

The following sample code converts a a 3D coordinate from a Celestiodetic SRF to a Celestiocentric SRF using the SRM C API:
#include 
#include 

#include "srm_level_0.h"

int main
(
    int argc,
    char* argv[]
)
{
    SRM_SRF cc_srf;
    SRM_SRF cd_srf;

    SRM_Coordinate cd_coord;
    SRM_CD_3D_Coordinate cd_coord_info;

    SRM_Coordinate cc_coord;
    SRM_Euclidean_3D_Coordinate cc_coord_info;

    SRM_ORM_Parameters cc_params;
    SRM_ORM_Parameters cd_params;

    SRM_Status_Code status;

    printf( "Running SRM Sample test program...\n" );

    cc_params.orm_code = SRM_ORM_WGS_1984;
    cc_params.hsr_code = SRM_HSR_WGS_1984_IDENTITY;

    cd_params.orm_code = SRM_ORM_WGS_1984;
    cd_params.hsr_code = SRM_HSR_WGS_1984_IDENTITY;

    if(( status = SRM_CreateSRF_CC( cc_params, &cc_srf )) != SRM_STAT_CODE_SUCCESS )
    {
        fprintf( stderr, "Failed to create CC SRF\n" );
    }
    else if(( status = SRM_CreateSRF_CD( cd_params, &cd_srf )) != SRM_STAT_CODE_SUCCESS )
    {
        fprintf( stderr, "Failed to create CD SRF\n" );
        SRM_FreeSRF( cc_srf );
    }
    else
    {
        cd_coord_info.longitude = 0.0;
        cd_coord_info.latitude = 0.785398163397;
        cd_coord_info.ellipsoidal_height = 0.0;

        if(( status = SRM_CreateCoordinateCD_3D( cd_srf, &cd_coord_info, &cd_coord )) != SRM_STAT_CODE_SUCCESS )
        {
            fprintf( stderr, "Failed to create CD coordinate\n" );
        }
        else
        {
            if(( status = SRM_ChangeCoordinateSRF( cd_srf, cd_coord, cc_srf, &cc_coord, NULL )) != SRM_STAT_CODE_SUCCESS )
            {
                fprintf( stderr, "SRM_ChangeCoordinateSRF failed\n" );
            }
            else
            {
                if(( status = SRM_GetCoordinateEuclidean_3D( cc_coord, &cc_coord_info )) != SRM_STAT_CODE_SUCCESS )
                {
                    fprintf( stderr, "Failed to get CC coordinate information\n" );
                }
                else
                {
                    printf( "[ %f, %f, %f ]\n", cc_coord_info.u, cc_coord_info.v, cc_coord_info.w );
                }

                SRM_FreeCoordinate( cc_coord );
            }

            SRM_FreeCoordinate( cd_coord );
        }

        SRM_FreeSRF( cd_srf );
        SRM_FreeSRF( cc_srf );
    }

    return 0;
}
Executing the sample code would result the following output:
Running SRM Sample test program...
[ 4517590.878846, 0.000000, 4487348.408859 ]

Return to: Top

Copyright © 2004 SEDRIS