/*static*/ void Conversions::ecef2utm(double ecef_x,double ecef_y,double ecef_z,double* utm_north,double* utm_east,double *utm_alt, int *utm_zone) { double lat, lon, h; double north, east; char zone[4]; ecef2wgs(ecef_x,ecef_y,ecef_z,&lat,&lon,&h); int RefEllipsoid = 23;//WGS-84. See list with file "llh_utm.cpp" for id numbers LLtoUTM(RefEllipsoid, lat, lon, north, east, zone); *utm_alt = h; *utm_east = east; *utm_north = north; *utm_zone = (zone[0]-'0') * 10 + (zone[1] - '0'); }
//--------------------------------------------------------------------------- void __fastcall ThreadLecturaGPS::Execute() { double UTMNorthing; double UTMEasting; char UTMZone[4]; int ReferenceEllipsoid = 23; double Lat; double Long; // double time; double Latitud, lat1; double Longitud, lon1; AnsiString Dir_Longitud; AnsiString Trama; AnsiString TramaCorrecta; //for (int i=0; i<10;i++) CPS->RecibirTramaGPS(); while (!Fin){ try{ Trama = AnsiString(CPS->RecibirTramaGPS()); //Obtenemos las coordenadas GGA StringTokenizer *ST = new StringTokenizer(Trama, ","); TramaCorrecta = ST->NextToken(); //Nos aseguramos que la trama GGA es la buena comparando la cabecera //Para asegurarnos mas todavia, convendria contar el numero de comas de la trama. // GGA Trimble --> 14 comas if ((AnsiString("$GPGGA")) == TramaCorrecta){ if (LongitudCorrecta(14,Trama)){ time = (ST->NextToken());//.ToDouble(); Latitud = (ST->NextToken()).ToDouble(); ST->NextToken(); Longitud =(ST->NextToken()).ToDouble(); Dir_Longitud = ST->NextToken(); ST->NextToken();//fix ST->NextToken();//n sat ST->NextToken();//DOP UTM_Height = ST->NextToken().ToDouble(); delete ST; lat1 = floor(Latitud/100); Latitud = lat1+(Latitud/100-lat1)*100/60; lon1 = floor(Longitud/100); Longitud = lon1+(Longitud/100-lon1)*100/60; //East Longitudes are positive, West longitudes are negative. //North latitudes are positive, South latitudes are negative if (Dir_Longitud == AnsiString("W")) LLtoUTM(ReferenceEllipsoid, Latitud, -Longitud, UTMNorthing, UTMEasting, UTMZone); else LLtoUTM(ReferenceEllipsoid, Latitud, Longitud, UTMNorthing, UTMEasting, UTMZone); /***************************************************************/ /******* Actualizo ls variables de clase **********************/ /***************************************************************/ UTM_North = UTMNorthing; UTM_East = UTMEasting; }//if Longitud correcta }//if }catch(Exception &E){/*MessageBox(NULL,"Error al leer la posición","ERROR",MB_OK | MB_ICONERROR);*/ } } CPS->CerrarPuerto(); delete CPS; }
void LL2EN(int ReferenceEllipsoid, double Lat, double Long, double *pUTMNorthing, double *pUTMEasting, char *pszUTMZone) { LLtoUTM(ReferenceEllipsoid, Lat, Long, pUTMNorthing, pUTMEasting, pszUTMZone); }