00001 /* 00002 * Fimex, CoordinateSystem.h 00003 * 00004 * (C) Copyright 2009, met.no 00005 * 00006 * Project Info: https://wiki.met.no/fimex/start 00007 * 00008 * This library is free software; you can redistribute it and/or modify it 00009 * under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation; either version 2.1 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00015 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00016 * License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00021 * USA. 00022 * 00023 * Created on: Mar 15, 2010 00024 * Author: Heiko Klein 00025 */ 00026 00027 #ifndef COORDINATESYSTEM_H_ 00028 #define COORDINATESYSTEM_H_ 00029 00030 #include <functional> 00031 #include <vector> 00032 #include <boost/shared_ptr.hpp> 00033 #include <iostream> 00034 #include "fimex/coordSys/CoordinateAxis.h" 00035 #include "fimex/coordSys/Projection.h" 00036 00037 00038 namespace MetNoFimex 00039 { 00040 00041 //forward decl. 00042 class CDM; 00043 struct CoordSysImpl; 00044 00053 class CoordinateSystem 00054 { 00055 public: 00059 typedef boost::shared_ptr<const CoordinateAxis> ConstAxisPtr; 00063 typedef boost::shared_ptr<CoordinateAxis> AxisPtr; 00067 typedef std::vector<ConstAxisPtr> ConstAxisList; 00068 00072 CoordinateSystem(); 00073 explicit CoordinateSystem(const std::string& conventionName); 00074 virtual ~CoordinateSystem() {} 00075 00079 virtual std::string id() const; 00083 virtual std::string getConventionName() const; 00088 virtual void setConventionName(const std::string& conventionName); 00093 virtual bool isComplete(const std::string& varName) const; 00097 virtual void setComplete(const std::string& varName, bool set = true); 00102 virtual bool isCSFor(const std::string& varName) const; 00106 virtual void setCSFor(const std::string& varName, bool set = true); 00110 virtual bool isSimpleSpatialGridded() const; 00114 virtual void setSimpleSpatialGridded(bool set = true); 00118 virtual bool hasProjection() const; 00123 virtual boost::shared_ptr<const Projection> getProjection() const; 00127 virtual void setProjection(boost::shared_ptr<const Projection> proj); 00132 virtual bool hasAxisType(CoordinateAxis::AxisType type) const; 00138 virtual ConstAxisPtr findAxisOfType(CoordinateAxis::AxisType type) const; 00144 virtual ConstAxisPtr findAxisOfType(const std::vector<CoordinateAxis::AxisType>& types) const; 00150 virtual ConstAxisPtr getGeoXAxis() const; 00156 virtual ConstAxisPtr getGeoYAxis() const; 00162 virtual ConstAxisPtr getGeoZAxis() const; 00166 virtual ConstAxisPtr getTimeAxis() const; 00170 virtual ConstAxisList getAxes() const; 00175 virtual void setAxis(AxisPtr axis); 00176 private: 00177 boost::shared_ptr<CoordSysImpl> pimpl_; 00178 }; 00179 00183 std::ostream& operator<<(std::ostream& out, const CoordinateSystem& p); 00184 00192 std::vector<boost::shared_ptr<const CoordinateSystem> > listCoordinateSystems(const CDM& cdm); 00193 00197 struct CompleteCoordinateSystemForComparator : public std::unary_function<boost::shared_ptr<const CoordinateSystem>, bool> 00198 { 00199 public: 00200 CompleteCoordinateSystemForComparator(const std::string& varName) : varName(varName) {} 00201 virtual ~CompleteCoordinateSystemForComparator() {} 00202 bool operator()(const boost::shared_ptr<const CoordinateSystem>& cs) {return cs->isComplete(varName) && cs->isCSFor(varName);} 00203 private: 00204 const std::string& varName; 00205 00206 }; 00207 00208 } 00209 00210 #endif /* COORDINATESYSTEM_H_ */