Table B.1 lists the topics in this annex:
Objects are created by invoking the relevant creation function for the type of object to be created as depicted in the following code segment:
#include <srm.h> SRM_ORM_Code example_orm; SRM_RT_Code example_rt; SRM_Celestiocentric example_object;example_orm = SRM_ORMCOD_EUROPE_1979; example_rt = SRM_RTCOD_EUROPE_1979_MEAN_SOLUTION ; SRM_CC_Create(example_orm, example_rt, &example_object);
When the function returns, example_object will have a properly updated state that points to implementation-specific private data that describes the object state and methods will contain a list of the methods that may be invoked for this SRF.
Once an object is created, its methods may be invoked to perform operations on the object. The following example continues the code segment above and depicts the creation of a 3D coordinate object:
SRM_Coordinate3D example_coordinate; example_object.methods.CreateCoordinate3D(&example_object, 10.0, 20.0, 30.0, &example_coordinate);
When the method returns, the object example_coordinate will contain a representation of the coordinate.
The following method invocation depicts returning the component values for the coordinate:
SRM_Long_Float component_1; SRM_Long_Float component_2; SRM_Long_Float component_3; example_object.methods.GetCoordinate3DValues(&example_object, &example_coordinate, &component_1, &component_2, &component_3);
When the GetCoordinate3DValues method returns, component_1 will contain 10,0, component_2 will contain 20,0, and component_3 will contain 30,0.
The following code illustrates the task of computing the Euclidean distance as specified in 10.6 Euclidean distance of ISO/IEC 18026.
#include "srm.h"
#include "math.h"
SRM_Status_Code status = SRM_STAT_CODE_SUCCESS;
SRM_Celestiodetic ex1_srf;
SRM_Coordinate3D coordinate1, coordinate2;
SRM_Long_Float distance = 0.0;
status = SRM_CD_Create(SRM_ORMCOD_N_AM_1983,
SRM_RTCOD_N_AM_1983_CONTINENTAL_US,
&ex1_srf);
status = ex1_srf.methods->CreateCoordinate3D(&ex1_srf,
(-77.0 * (M_PI / 180.0)),
(38.0 * (M_PI / 180.0)),
0.0,
&coordinate1);
status = ex1_srf.methods->CreateCoordinate3D(&ex1_srf,
(3.0 * (M_PI / 180.0)),
(49.0 * (M_PI / 180.0)),
0.0,
&coordinate2);
status = ex1_srf.methods->EuclideanDistance3D(&ex1_srf,
&coordinate1,
&coordinate2,
&distance);
fprintf(stdout,
"The Euclidean distance between coordinate1 and coordinate2 is %lf\n",
distance);
status = coordinate1.methods->Destroy(&coordinate1);
status = coordinate1.methods->Destroy(&coordinate1);
status = ex1_srf.methods->Destroy(&ex1_srf);
The following code illustrates the task of converting a coordinate in a standard SRF to a coordinate in an SRF set member.
#include "srm.h"
SRM_Status_Code status = SRM_STAT_CODE_SUCCESS;
SRM_Coordinate3D source_coordinate, target_coordinate;
SRM_BaseSRF source_srf, target_srf;
SRM_Coordinate_Valid_Region region;
status = SRM_CreateSRFSetMember(SRM_SRFS_UNIVERSAL_TRANSVERSE_MERCATOR,
SRM_SRFSMUTMCOD_ZONE_23_NORTHERN_HEMISPHERE,
SRM_ORMCOD_N_AM_1983,
SRM_RTCOD_N_AM_1983_CONTINENTAL_US,
&source_srf);
status = ((SRM_TransverseMercator *)&source_srf)->
methods->CreateCoordinate3D(&source_srf,
350000.0,
400.0,
0.0,
&source_coordinate);
status = SRM_CreateStandardSRF(SRM_SRF_GEOCENTRIC_WGS_1984, &target_srf);
status = ((SRM_Celestiocentric *)&target_srf)->
methods->ChangeCoordinate3DSRF(&target_srf,
&source_srf,
source_coordinate,
&target_coordinate,
®ion);
status = ((SRM_TransverseMercator *)&source_srf)->
methods->DestroyCoordinate3D(&source_coordinate);
status = ((SRM_Celestiocentric *) &target_srf)->
methods->DestroyCoordinate3D(&target_coordinate);
status = ((SRM_TransverseMercator *)&source_srf)->
methods->Destroy(&source_srf);
status = ((SRM_Celestiocentric *) &target_srf)->
methods->Destroy(&target_srf);
http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_IEC_18042-4_Ed1.html