MI - Fimex
CoordinateSystem.h
Go to the documentation of this file.
1 /*
2  * Fimex, CoordinateSystem.h
3  *
4  * (C) Copyright 2009, 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: Mar 15, 2010
24  * Author: Heiko Klein
25  */
26 
27 #ifndef COORDINATESYSTEM_H_
28 #define COORDINATESYSTEM_H_
29 
30 #include <functional>
31 #include <vector>
32 #include <map>
33 #include <set>
34 #include <string>
35 #include <boost/shared_ptr.hpp>
36 #include <iostream>
40 #include "fimex/deprecated.h"
41 
42 
43 namespace MetNoFimex
44 {
45 
46 //forward decl.
47 class CDM;
48 class CDMReader;
49 struct CoordSysImpl;
50 
60 {
61 public:
65  typedef boost::shared_ptr<const CoordinateAxis> ConstAxisPtr;
69  typedef boost::shared_ptr<CoordinateAxis> AxisPtr;
74 
79  explicit CoordinateSystem(const std::string& conventionName);
80  virtual ~CoordinateSystem() {}
81 
85  virtual std::string id() const;
90  virtual std::string horizontalId() const;
91 
95  virtual std::string getConventionName() const;
100  virtual void setConventionName(const std::string& conventionName);
105  virtual bool isComplete(const std::string& varName) const;
109  virtual void setComplete(const std::string& varName, bool set = true);
114  virtual bool isCSFor(const std::string& varName) const;
118  virtual void setCSFor(const std::string& varName, bool set = true);
122  virtual bool isSimpleSpatialGridded() const;
126  virtual void setSimpleSpatialGridded(bool set = true);
131  virtual bool hasProjection() const;
137  virtual boost::shared_ptr<const Projection> getProjection() const;
141  virtual void setProjection(boost::shared_ptr<const Projection> proj);
146  virtual bool hasVerticalTransformation() const;
152  virtual boost::shared_ptr<const VerticalTransformation> getVerticalTransformation() const;
156  virtual void setVerticalTransformation(boost::shared_ptr<const VerticalTransformation> vtran);
161  virtual bool hasAxisType(CoordinateAxis::AxisType type) const;
167  virtual ConstAxisPtr findAxisOfType(CoordinateAxis::AxisType type) const;
173  virtual ConstAxisPtr findAxisOfType(const std::vector<CoordinateAxis::AxisType>& types) const;
179  virtual ConstAxisPtr getGeoXAxis() const;
185  virtual ConstAxisPtr getGeoYAxis() const;
191  virtual ConstAxisPtr getGeoZAxis() const;
195  virtual ConstAxisPtr getTimeAxis() const;
199  virtual ConstAxisList getAxes() const;
204  virtual void setAxis(ConstAxisPtr axis);
209  virtual void setAuxiliaryAxis(ConstAxisPtr axis);
219  virtual void addDependencyVariable(std::string varName);
220 private:
221  boost::shared_ptr<CoordSysImpl> pimpl_;
222 };
223 
228 
250 void enhanceVectorProperties(boost::shared_ptr<CDMReader> reader);
251 
256 MIFI_DEPRECATED(std::vector<boost::shared_ptr<const CoordinateSystem> > listCoordinateSystems(CDM& cdm));
261 MIFI_DEPRECATED(std::vector<boost::shared_ptr<const CoordinateSystem> > listCoordinateSystems(const CDM& cdm));
262 
276 int findBestHorizontalCoordinateSystems(bool withProjection, boost::shared_ptr<CDMReader> reader, std::map<std::string, boost::shared_ptr<const CoordinateSystem> >& systems, std::map<std::string, std::string>& variables, std::vector<std::string>& incompatibleVariables);
277 
281 struct CompleteCoordinateSystemForComparator : public std::unary_function<boost::shared_ptr<const CoordinateSystem>, bool>
282 {
283 public:
284  CompleteCoordinateSystemForComparator(const std::string& varName) : varName(varName) {}
286  bool operator()(const boost::shared_ptr<const CoordinateSystem>& cs) {return cs->isComplete(varName) && cs->isCSFor(varName);}
287 private:
288  const std::string& varName;
289 
290 };
291 
292 }
293 
294 #endif /* COORDINATESYSTEM_H_ */
virtual ConstAxisPtr getGeoYAxis() const
virtual void setCSFor(const std::string &varName, bool set=true)
virtual ConstAxisPtr getTimeAxis() const
basic_string< char > string
virtual bool isSimpleSpatialGridded() const
virtual bool hasAxisType(CoordinateAxis::AxisType type) const
Definition: CoordinateSystem.h:281
virtual boost::shared_ptr< const Projection > getProjection() const
AxisType
Definition: CoordinateAxis.h:41
virtual void addDependencyVariable(std::string varName)
STL class.
virtual std::string horizontalId() const
virtual ConstAxisPtr getGeoXAxis() const
Definition: CoordinateSystem.h:59
virtual bool isCSFor(const std::string &varName) const
virtual void setVerticalTransformation(boost::shared_ptr< const VerticalTransformation > vtran)
basic_ostream< char > ostream
MIFI_DEPRECATED(std::vector< CDMAttribute > projStringToAttributes(std::string projStr))
convert a proj4 string to a list of CDMAttributes usable for CF-1.0 projection variable ...
STL class.
Data structure of the Common Data Model.
Definition: CDM.h:54
virtual void setComplete(const std::string &varName, bool set=true)
virtual void setProjection(boost::shared_ptr< const Projection > proj)
void enhanceVectorProperties(boost::shared_ptr< CDMReader > reader)
Definition: C_CDMReader.h:35
virtual ~CoordinateSystem()
Definition: CoordinateSystem.h:80
boost::shared_ptr< const CoordinateAxis > ConstAxisPtr
Definition: CoordinateSystem.h:65
virtual void setAuxiliaryAxis(ConstAxisPtr axis)
std::vector< ConstAxisPtr > ConstAxisList
Definition: CoordinateSystem.h:73
virtual ConstAxisPtr findAxisOfType(CoordinateAxis::AxisType type) const
CompleteCoordinateSystemForComparator(const std::string &varName)
Definition: CoordinateSystem.h:284
std::vector< boost::shared_ptr< const CoordinateSystem > > listCoordinateSystems(boost::shared_ptr< CDMReader > reader)
virtual ConstAxisPtr getGeoZAxis() const
std::ostream & operator<<(std::ostream &out, CoordinateAxis ca)
virtual void setAxis(ConstAxisPtr axis)
virtual void setConventionName(const std::string &conventionName)
virtual ConstAxisList getAxes() const
virtual std::string id() const
int findBestHorizontalCoordinateSystems(bool withProjection, boost::shared_ptr< CDMReader > reader, std::map< std::string, boost::shared_ptr< const CoordinateSystem > > &systems, std::map< std::string, std::string > &variables, std::vector< std::string > &incompatibleVariables)
boost::shared_ptr< CoordinateAxis > AxisPtr
Definition: CoordinateSystem.h:69
virtual boost::shared_ptr< const VerticalTransformation > getVerticalTransformation() const
virtual bool isComplete(const std::string &varName) const
virtual ~CompleteCoordinateSystemForComparator()
Definition: CoordinateSystem.h:285
virtual std::string getConventionName() const
virtual void setSimpleSpatialGridded(bool set=true)
virtual bool hasVerticalTransformation() const
virtual std::set< std::string > getDependencyVariables() const
virtual bool hasProjection() const
bool operator()(const boost::shared_ptr< const CoordinateSystem > &cs)
Definition: CoordinateSystem.h:286