"Fossies" - the Fresh Open Source Software Archive

Member "fimex-1.4.1/include/fimex/coordSys/Projection.h" (30 Oct 2019, 4226 Bytes) of package /linux/privat/fimex-1.4.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Projection.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.3.3_vs_1.4.0.

    1 /*
    2  * Fimex, Projection.h
    3  *
    4  * (C) Copyright 2010-2019, met.no
    5  *
    6  * Project Info:  https://wiki.met.no/fimex/start
    7  *
    8  * This library is free software; you can redistribute it and/or modify it
    9  * under the terms of the GNU Lesser General Public License as published by
   10  * the Free Software Foundation; either version 2.1 of the License, or
   11  * (at your option) any later version.
   12  *
   13  * This library is distributed in the hope that it will be useful, but
   14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   15  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
   16  * License for more details.
   17  *
   18  * You should have received a copy of the GNU Lesser General Public
   19  * License along with this library; if not, write to the Free Software
   20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
   21  * USA.
   22  *
   23  *  Created on: Apr 27, 2010
   24  *      Author: Heiko Klein
   25  */
   26 
   27 #ifndef PROJECTION_H_
   28 #define PROJECTION_H_
   29 
   30 #include "CoordSysDecl.h"
   31 #include "fimex/CDMAttribute.h"
   32 
   33 #include <iosfwd>
   34 
   35 namespace MetNoFimex
   36 {
   37 
   38 /**
   39  * @headerfile fimex/coordSys/Projection.h
   40  */
   41 /**
   42  * A projection describes a projection of the earth surface from one system
   43  * to another. If not mentioned otherwise, all parameters should follow CF-1.x
   44  */
   45 class Projection : public CDMNamedEntity
   46 {
   47 public:
   48     ~Projection();
   49     virtual std::vector<CDMAttribute> getParameters() const = 0;
   50     virtual void addParameter(CDMAttribute attribute) = 0;
   51     virtual void addParameters(std::vector<CDMAttribute> attributes) = 0;
   52     virtual void removeParameter(std::string paramName) = 0;
   53     /** check if the coordinates belonging to this projection are in degree (otherwise metrical) */
   54     virtual bool isDegree() const = 0;
   55     /** get a proj4 string */
   56     virtual std::string getProj4String() const = 0;
   57     /**
   58      * get the parts of the proj4 string defining the earth.
   59      */
   60     virtual std::string getProj4EarthString() const = 0;
   61     /**
   62      * convert two vectors of values in the projection to latitude and longitude
   63      * in degree. The earth ellipsoid will be the same as the input.
   64      *
   65      * @param xVals input of the projection axis in meter or degree, output is longitude
   66      * @param yVals input of the projection axis in meter or degree, output is latitude
   67      *
   68      * @warning the values will be converted in place
   69      */
   70     virtual void convertToLonLat(std::vector<double>& xVals, std::vector<double>& yVals) const;
   71     /**
   72      * convert two vectors of values in the projection to latitude and longitude
   73      * in degree. The earth ellipsoid will be the same as the input.
   74      *
   75      * @param xVals longitude input in degree, output of the projection axis in meter or degree
   76      * @param yVals latitude input in degree, output of the projection axis in meter or degree
   77      *
   78      * @warning the values will be converted in place
   79      */
   80     virtual void convertFromLonLat(std::vector<double>& xVals, std::vector<double>& yVals) const;
   81     /**
   82      * get a string representation
   83      * @note this should be implemented as unique as possible, i.e.
   84      */
   85     virtual std::string toString() const = 0;
   86     /**
   87      * Comparison of two projections, implemented using the toString() function.
   88      * This function does not guarantee that two projections are physically equal.
   89      */
   90     virtual bool operator==(const  Projection& b) const;
   91 
   92     /** create a projection from some CDMAttributes */
   93     static Projection_p create(const std::vector<CDMAttribute>&);
   94 
   95     /** create a projection from a proj4 string */
   96     static Projection_p createByProj4(const std::string& projStr);
   97 
   98 protected:
   99     Projection() {}
  100 };
  101 
  102 /** output-stream for projections, implemented using toString() */
  103 std::ostream& operator<<(std::ostream& out, const Projection& proj);
  104 
  105 /**
  106  *
  107  * helper function to
  108  * replace the earth figure of the given proj4 string with a new earth-figure
  109  *
  110  * @param proj4 original proj-string
  111  * @param newEarthfigure earth-figure in proj-format, e.g. +ellps=sphere +R=6371000 +towgs84=0,0,0
  112  */
  113 std::string replaceProj4Earthfigure(const std::string& proj4, const std::string& newEarthfigure);
  114 
  115 } /* namespace MetNoFimex */
  116 
  117 #endif /* PROJECTION_H_ */