Get Methods

WRAPPER_API [Type] *Get[Type](const BmgChar *code) const

WRAPPER_API [Type] *Get[Type](const BmgChar *issuer, const BmgChar *code) const

 

Above, [Type] is a placeholder for the class name of the desired object.

 

Description

The DataSource contains a 'Get' method for each type of object that one can get from the data source.  For example, to get an AngularUnit from the data source, you would use the GetAngularUnit method, whereas to get a GeodeticCoordSys, you would use the GetGeodeticCoordSys method..  

There are two signatures for the 'Get' methods, one of which takes a single string argument, and the other of which takes two string arguments.  If you use the signature that takes one argument, the argument specifies the Code for the desired object.  The DefaultIssuer property will be used as the Issuer to identify the object in the data source.  If you use the signature that takes two arguments, the first argument gives the issuer and the second argument gives the code to identify the object in the data source.  

If the specified identifier does not exist in the DataSource, a GeoCalcException will be thrown with ErrorCode specifying IdentifierNotFound.

The signatures of this method are different in the case of a Serializable object, where one must specify the DataSource::ObjectType that corresponds to the type of the Serializable.  In order to get a Serializable with the default issuer, one would call GetSerializable, specifying the ObjectType as the first argument and the code as the second argument.  In order to get a Serializable by specifying the issuer, on would call GetSerializable, specifying the ObjectType as the first argument, the issuer as the second argument, and the code as the third argument.

It is the user's responsibility to free objects returned by the 'Get' methods.

The following example shows how to use the 'Get' method to get a ProjectedCoordSys, but the usage is the same for all objects with the exception of Serializable.  

 

Example

void DataSource_Get(GEOCALCPBW_NAMESPACE::DataSource & data)

{

_towchar issuer("BMG");

_towchar code("AK9-27");

GEOCALCPBW_NAMESPACE::ProjectedCoordSys * cs = NULL;

try

{

cs = data.GetProjectedCoordSys(issuer.c_str(), code.c_str());

}

catch(GEOCALCPBW_NAMESPACE::GeoCalcException & ex)

{

if(ex.get_ErrorCode() == GEOCALCPBW_NAMESPACE::GeoCalcException::Code::IdentifierNotFound)

{

AfxMessageBox("GetProjectedCoordSys failed: invalid identifier");

}

}

if(cs != NULL)

{

_towchar filename("c:\\MyCoordSys.wkt");

if(! data.ExportCoordSysToFile(*cs, filename.c_str()))

{

AfxMessageBox("ExportCoordSysToFile failed");

}

delete cs;

}

}