SimApi Convertor UTMtoWGS

From SIMboxWiki
Jump to navigation Jump to search

Icon attributes.pngstatic bool SimApi::Convertor::UTMtoWGS(double i_UTM_X, double i_UTM_Y, int i_UTM_Zone, bool i_UTM_IsSouthHemi, double &o_WGS_Lon, double &o_WGS_Lat)


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


    i_UTM_X - The X coordinate of UTM format (meters)
    i_UTM_Y - The Y coordinate of UTM format (meters)
    i_UTM_Zone - The UTM zone of the coordinates.
    i_UTM_IsSouthHemi - True: the coordinates are in the south hemisphere, False: the coordinates are in the north hemisphere.
    o_WGS_Lon - The longitude coordinate of WGS84 format (radians)
    o_WGS_Lat - The latitude coordinate of WGS84 format (radians)


    Type: bool   Description: true if the conversion succeeded, the WGS84 coordinates are returned in o_WGS_Lon and o_WGS_Lat parameters

    Code Sample

          void MyUTMtoLocal(const double & i_UTMX,const double & i_UTMY,const int & i_UTM_Zone,const bool & i_UTM_IsSouthHemi, float & o_X, float & o_Y)
	double latitude = 0.0;
	double longitude = 0.0;
	//convert UTM to global
	SimApi::Convertor::UTMtoWGS (i_UTMX, i_UTMY, i_UTM_Zone, i_UTM_IsSouthHemi, longitude, latitude);
	//Print converted world local coordinates:
	cout<<"Longitude: "<<longitude<<endl;
	cout<<"Latitude: "<<latitude<<endl;
	//convert global position to simulation local position
	SimApi::Convertor::globalToLocal(longitude , latitude ,o_X,o_Y);

int main(int argc, char* argv[])
	double utmX = 720000;
	double utmY = 4020000;
	double utmZone = 11;
	float x,y;
	MyUTMtoLocal(utmX, utmY, utmZone, false, x, y);
	//print results
	cout<<"Position X: "<<x<<endl;
	cout<<"Position Y: "<<y<<endl;
	return 0;

Longitude: -1.9992734507584144
Latitude: 0.63355304558652181

Position X: 33193.926
Position Y: 35859.938

    See Also


    Related Links

     SIMbox Coordinates Systems Overview