SimApi Convertor WGStoUTM

From SIMboxWiki
Jump to navigation Jump to search

Icon attributes.pngstatic bool SimApi::Convertor::WGStoUTM(double i_WGS_Lon, double i_WGS_Lat, double &o_UTM_X, double &o_UTM_Y, int &io_UTM_Zone, bool i_AutoComputeUTMZone, bool &o_UTM_IsSouthHemi)


    Converts global geographic coordinates (given in WGS84 format) to global UTM coordinates.


    i_WGS_Lon - The longitude coordinate of WGS84 format (degrees)
    i_WGS_Lat - The latitude coordinate of WGS84 format (degrees)
    o_UTM_X - The X coordinate of UTM format (meters)
    o_UTM_Y - The Y coordinate of UTM format (meters)
    io_UTM_Zone - The UTM zone of the coordinates.
    i_AutoComputeUTMZone - True: recompute best fit UTM zone according the coordinates, False: use the value passed in io_UTM_Zone .
    o_UTM_IsSouthHemi - True: the coordinates are in the south hemisphere, False: the coordinates are in the north hemisphere.


    Type: bool   Description: true if the conversion succeeded, the UTM coordinates are returned in the o_UTM_X ,o_UTM_Y, o_UTM_IsSouthHemi parameters.

    Code Sample

          void MyUTMConversion(double i_Longitude, double i_Latitude)
	double UTMX = 0.0;
	double UTMY = 0.0;
	int UTM_Zone = 0;
	bool IsSouthHemiSphere = false;

	//convert global pos to UTM
	SimApi::Convertor::WGStoUTM(i_Longitude, i_Latitude, UTMX, UTMY, UTM_Zone, true, IsSouthHemiSphere);

	//print results
	cout<<"UTM X: "<<(int)UTMX<<endl;
	cout<<"UTM Y: "<<(int)UTMY<<endl;
	cout<<"UTM Zone: "<<UTM_Zone<<endl;

int main(int argc, char* argv[])
	// Latitude and Longitude in degrees 
	double lat = 36.0;
	double lon = -115.0;
	MyUTMConversion(lon, lat);

	return 0;


UTM X: 680266
UTM Y: 3985798
UTM Zone: 11

    See Also



    Related Links

     SIMbox Coordinates Systems Overview