/*! * Actual function which does the conversion from LLA to Map Coords. * * @param lat: Latitude coords. * @param lon: Longitude coords. * @param alt: Altitude coords. * @param ea: East coords. * @param no: North coords. * @param up: Up coords. * * @return true if conversion is possible else false. * */ AREXPORT bool ArMapGPSCoords::convertLLA2MapCoords(const double lat, const double lon, const double alt, double& ea, double& no, double& up) const { if(!myOriginSet) return false; ArLLACoords lla(lat, lon, alt); ArECEFCoords ecef = lla.LLA2ECEF(); ArENUCoords enu = ecef.ECEF2ENU(*myOriginECEF); // ArLog::log(ArLog::Normal, "GPSLocaLog: convertLLA2MapCoords: ENU %g %g %g", // enu.getX(), enu.getY(), enu.getZ()); ea = enu.getX();//enu(0); no = enu.getY();//enu(1); up = enu.getZ();//enu(2); // ArLog::log(ArLog::Normal, // "GPSLocaLog: convertLLA2MapCoords: ENU + offset %g %g %g", // ea, no, up); return true; }
int main(int argc, char **argv) { // Initialize Aria and Arnl global information Aria::init(); ArLLACoords originLatLon(42.805464, -71.574738, 64.0); ArMapGPSCoords mapGPSCoords(originLatLon); ArLog::log(ArLog::Normal, "Origin LLA is %.6f %.6f %g", originLatLon.getLatitude(), originLatLon.getLongitude(), originLatLon.getAltitude()); // Line of points along longitude. for(int i = 0; i < 10; i++) { double di = (double) i * 1e-6; ArLLACoords lla(originLatLon.getLatitude(), originLatLon.getLongitude() + di, originLatLon.getAltitude()); double ea, no, up; mapGPSCoords.convertLLA2MapCoords(lla.getLatitude(), lla.getLongitude(), lla.getAltitude(), ea, no, up); ArLog::log(ArLog::Normal, "LLA %.6f %.6f %g (deg deg m)-> ENU %.2f %.2f %.2f (mm)", lla.getLatitude(), lla.getLongitude(), lla.getAltitude(), ea, no, up); } // Line of points along latitude. for(int i = 0; i < 10; i++) { double di = (double) i * 1e-6; ArLLACoords lla(originLatLon.getLatitude() + di, originLatLon.getLongitude(), originLatLon.getAltitude()); double ea, no, up; mapGPSCoords.convertLLA2MapCoords(lla.getLatitude(), lla.getLongitude(), lla.getAltitude(), ea, no, up); ArLog::log(ArLog::Normal, "LLA %.6f %.6f %g (deg deg m)-> ENU %.2f %.2f %.2f (mm)", lla.getLatitude(), lla.getLongitude(), lla.getAltitude(), ea, no, up); } // Line of points along east. for(int i = 0; i < 10; i++) { double di = (double) i * 1000.0; double lat, lon, alt; double ea=di, no=0.0, up=0.0; mapGPSCoords.convertMap2LLACoords(ea, no, up, lat, lon, alt); ArLog::log(ArLog::Normal, "ENU %g %g %g (mm) -> LLA %.6f %.6f %g (deg deg m)", ea, no, up, lat, lon, alt); } // Line of points along north. for(int i = 0; i < 10; i++) { double di = (double) i * 1000.0; double lat, lon, alt; double ea=0.0, no=di, up=0.0; mapGPSCoords.convertMap2LLACoords(ea, no, up, lat, lon, alt); ArLog::log(ArLog::Normal, "ENU %g %g %g (mm) -> LLA %.6f %.6f %g (deg deg m)", ea, no, up, lat, lon, alt); } Aria::exit(0); }
Vector3 Utilities::latLonToECEF(LatLon latLon) { scene::LatLonAlt lla(latLon.getLat(), latLon.getLon()); return latLonToECEF(lla); }