XYZ2NEU.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: XYZ2NEU.cpp 3140 2012-06-18 15:03:02Z susancummins $"
00002 
00009 //============================================================================
00010 //
00011 //  This file is part of GPSTk, the GPS Toolkit.
00012 //
00013 //  The GPSTk is free software; you can redistribute it and/or modify
00014 //  it under the terms of the GNU Lesser General Public License as published
00015 //  by the Free Software Foundation; either version 2.1 of the License, or
00016 //  any later version.
00017 //
00018 //  The GPSTk is distributed in the hope that it will be useful,
00019 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 //  GNU Lesser General Public License for more details.
00022 //
00023 //  You should have received a copy of the GNU Lesser General Public
00024 //  License along with GPSTk; if not, write to the Free Software Foundation,
00025 //  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
00026 //
00027 //  Dagoberto Salazar - gAGE ( http://www.gage.es ). 2007, 2008, 2011
00028 //
00029 //============================================================================
00030 
00031 
00032 #include "XYZ2NEU.hpp"
00033 
00034 
00035 namespace gpstk
00036 {
00037 
00038       // Returns a string identifying this object.
00039    std::string XYZ2NEU::getClassName() const
00040    { return "XYZ2NEU"; }
00041 
00042 
00043 
00044       /* Common constructor taking reference point Position object
00045        *
00046        * @param refPos    Reference point Position object.
00047        */
00048    XYZ2NEU::XYZ2NEU(const Position& refPos)
00049    {
00050 
00051       setLatLon( refPos.getGeodeticLatitude(),
00052                  refPos.getLongitude() );
00053 
00054    }  // End of 'XYZ2NEU::XYZ2NEU()'
00055 
00056 
00057 
00058       /* Method to set the latitude of the reference point, in degrees.
00059        *
00060        * @param lat      Latitude of the reference point, in degrees.
00061        *
00062        * @warning If parameter 'lat' is outside the +90/-90 degrees range,
00063        * then latitude will be set to 0 degrees.
00064        */
00065    XYZ2NEU& XYZ2NEU::setLat(const double& lat)
00066    {
00067          // Don't allow latitudes out of the -90/+90 interval
00068       if ( (lat > 90.0) ||
00069            (lat < -90.0)   )
00070       {
00071          refLat = 0.0;
00072       }
00073       else
00074       {
00075          refLat = (lat*DEG_TO_RAD);
00076       }
00077 
00078       init();
00079 
00080       return (*this);
00081 
00082    }  // End of method 'XYZ2NEU::setLat()'
00083 
00084 
00085 
00086       /* Method to set the longitude of the reference point, in degrees.
00087        *
00088        * @param lon       Longitude of the reference point, in degrees.
00089        */
00090    XYZ2NEU& XYZ2NEU::setLon(const double& lon)
00091    {
00092 
00093       refLon = (lon*DEG_TO_RAD);
00094 
00095       init();
00096 
00097       return (*this);
00098 
00099    }  // End of method 'XYZ2NEU::setLon()'
00100 
00101 
00102 
00103       /* Method to simultaneously set the latitude and longitude of the
00104        *  reference point, in degrees.
00105        *
00106        * @param lat        Latitude of the reference point, in degrees.
00107        * @param lon        Longitude of the reference point, in degrees.
00108        *
00109        * @warning If parameter 'lat' is outside the +90/-90 degrees range,
00110        * then latitude will be set to 0 degrees.
00111        */
00112    XYZ2NEU& XYZ2NEU::setLatLon( const double& lat,
00113                                 const double& lon )
00114    {
00115 
00116          // Don't allow latitudes out of the -90/+90 interval
00117       if ( (lat > 90.0) ||
00118            (lat < -90.0)  )
00119       {
00120          refLat = 0.0;
00121       }
00122       else
00123       {
00124          refLat = (lat*DEG_TO_RAD);
00125       }
00126 
00127       refLon = (lon*DEG_TO_RAD);
00128 
00129       init();
00130 
00131       return (*this);
00132 
00133    }  // End of method 'XYZ2NEU::setLatLon()'
00134 
00135 
00136 
00137       // Returns a reference to a satTypeValueMap object after converting
00138       // from a geocentric reference system to a topocentric reference system.
00139       //
00140       // @param gData     Data object holding the data.
00141       //
00142    satTypeValueMap& XYZ2NEU::Process(satTypeValueMap& gData)
00143       throw(ProcessingException)
00144    {
00145 
00146       try
00147       {
00148 
00149          Matrix<double> neuMatrix;
00150 
00151             // Get the corresponding geometry/design matrix data
00152          Matrix<double> dMatrix(gData.getMatrixOfTypes(inputSet));
00153 
00154             // Compute the base change. For convenience, we use the property:
00155             // Y = A*B => Y^T = (A*B)^T => Y^T = B^T * A^T
00156          neuMatrix = dMatrix*rotationMatrix;
00157 
00158          gData.insertMatrix(outputSet, neuMatrix);
00159 
00160          return gData;
00161 
00162       }
00163       catch(Exception& u)
00164       {
00165             // Throw an exception if something unexpected happens
00166          ProcessingException e( getClassName() + ":"
00167                                 + u.what() );
00168 
00169          GPSTK_THROW(e);
00170 
00171       }
00172 
00173    }  // End of method 'XYZ2NEU::Process()'
00174 
00175 
00176 
00177       // This method builds the rotation matrix according to 'refLat'
00178       // and 'refLon' values.
00179    void XYZ2NEU::init()
00180    {
00181 
00182          // First, let's resize rotation matrix and assign the proper values
00183       rotationMatrix.resize(3,3);
00184 
00185          // The clasical rotation matrix is transposed here for convenience
00186       rotationMatrix(0,0) = -std::sin(refLat)*std::cos(refLon);
00187       rotationMatrix(1,0) = -std::sin(refLat)*std::sin(refLon);
00188       rotationMatrix(2,0) = std::cos(refLat);
00189       rotationMatrix(0,1) = -std::sin(refLon);
00190       rotationMatrix(1,1) = std::cos(refLon);
00191       rotationMatrix(2,1) = 0.0;
00192       rotationMatrix(0,2) = std::cos(refLat)*std::cos(refLon);
00193       rotationMatrix(1,2) = std::cos(refLat)*std::sin(refLon);
00194       rotationMatrix(2,2) = std::sin(refLat);
00195 
00196          // Then, fill the sets with the proper types
00197       inputSet.clear();
00198       inputSet.insert(TypeID::dx);
00199       inputSet.insert(TypeID::dy);
00200       inputSet.insert(TypeID::dz);
00201 
00202       outputSet.clear();
00203       outputSet.insert(TypeID::dLat);
00204       outputSet.insert(TypeID::dLon);
00205       outputSet.insert(TypeID::dH);
00206 
00207    }  // End of method 'XYZ2NEU::init()'
00208 
00209 
00210 }  // End of namespace gpstk

Generated on Wed Jun 19 03:31:12 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1