"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/metgm/MetGmHorizontalTag.cc" between
fimex-1.4.1.tar.gz and fimex-1.4.2.tar.gz

About: Fimex is a the File Interpolation, Manipulation and EXtraction library for gridded geospatial data. It converts between different, extensible dataformats (currently netcdf, NcML, grib1/2 and felt).

MetGmHorizontalTag.cc  (fimex-1.4.1):MetGmHorizontalTag.cc  (fimex-1.4.2)
/* /*
* Fimex * Fimex
* *
* (C) Copyright 2011, met.no * (C) Copyright 2011-2019, met.no
* *
* Project Info: https://wiki.met.no/fimex/start * Project Info: https://wiki.met.no/fimex/start
* *
* This library is free software; you can redistribute it and/or modify it * This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by * under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, but * This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
skipping to change at line 40 skipping to change at line 40
// //
#include "fimex/coordSys/CoordinateSystem.h" #include "fimex/coordSys/CoordinateSystem.h"
namespace MetNoFimex { namespace MetNoFimex {
std::shared_ptr<MetGmXTag> MetGmHorizontalTag::createMetGmXTagForWriting(const C DMReader_p pCdmReader, const CDMVariable* pVariable) std::shared_ptr<MetGmXTag> MetGmHorizontalTag::createMetGmXTagForWriting(const C DMReader_p pCdmReader, const CDMVariable* pVariable)
{ {
if (!pVariable) if (!pVariable)
throw CDMException("pVar is null"); throw CDMException("pVar is null");
if (!pCdmReader.get()) if (!pCdmReader)
throw CDMException("pCdmReader is null"); throw CDMException("pCdmReader is null");
std::shared_ptr<MetGmXTag> XTag; std::shared_ptr<MetGmXTag> XTag;
const CoordinateSystem_cp_v coordSys = listCoordinateSystems(pCdmReader); CoordinateSystem_cp cs = findCompleteCoordinateSystemFor(listCoordinateSyste
ms(pCdmReader), pVariable->getName());
CoordinateSystem_cp cs = findCompleteCoordinateSystemFor(coordSys, pVariable if (cs && cs->isSimpleSpatialGridded() && cs->getGeoXAxis()) {
->getName()); XTag = std::shared_ptr<MetGmXTag>(new MetGmXTag);
if (cs.get()) {
if (cs->isSimpleSpatialGridded()) { DataPtr data = pCdmReader->getScaledDataInUnit(cs->getGeoXAxis()->getNam
e(), "degree");
CoordinateAxis_cp xAxis = cs->getGeoXAxis(); XTag->numberOfPoints_ = data->size();
XTag->extractHorizontalPoints(data);
if (!xAxis.get()) {
return std::shared_ptr<MetGmXTag>(); XTag->center_ = (XTag->horizontalPoints_.back() + XTag->horizontalPoints
} _.front()) / 2.0;
XTag->distance_ = XTag->horizontalPoints_.at(1) - XTag->horizontalPoints
XTag = std::shared_ptr<MetGmXTag>(new MetGmXTag); _.front();
if (XTag->distance_ < 0)
DataPtr data = pCdmReader->getScaledDataInUnit(xAxis->getName(), "de throw CDMException("metgm is not supporting negative distances on lo
gree"); ngitude axis");
XTag->numberOfPoints_ = data->size();
XTag->extractHorizontalPoints(data);
XTag->center_ = (XTag->horizontalPoints_.at(XTag->horizontalPoints_.
size() - 1) + XTag->horizontalPoints_.at(0)) / 2.0;
XTag->distance_ = XTag->horizontalPoints_.at(1) - XTag->horizontalPo
ints_.at(0);
if (XTag->distance_ < 0)
throw CDMException("metgm is not supporting negative distances o
n longitude axis");
}
} else {
} }
return XTag; return XTag;
} }
std::shared_ptr<MetGmYTag> MetGmHorizontalTag::createMetGmYTagForWriting(con
st CDMReader_p pCdmReader, const CDMVariable* pVariable)
{
if(!pVariable)
throw CDMException("pVar is null");
if(!pCdmReader.get())
throw CDMException("pCdmReader is null");
std::shared_ptr<MetGmYTag> YTag;
const CoordinateSystem_cp_v coordSys = listCoordinateSystems(pCdmReader)
;
CoordinateSystem_cp cs = findCompleteCoordinateSystemFor(coordSys, pVari
able->getName());
if (cs.get()) {
if(cs->isSimpleSpatialGridded()) {
CoordinateAxis_cp yAxis = cs->getGeoYAxis();
if(!yAxis.get()) {
return std::shared_ptr<MetGmYTag>();
}
YTag = std::shared_ptr<MetGmYTag>(new MetGmYTag);
DataPtr data = pCdmReader->getScaledDataInUnit(yAxis->getName(),
"degree");
YTag->numberOfPoints_ = data->size();
YTag->extractHorizontalPoints(data);
YTag->center_ = (YTag->horizontalPoints_.at(YTag->horizontalPoin std::shared_ptr<MetGmYTag> MetGmHorizontalTag::createMetGmYTagForWriting(const C
ts_.size() - 1) + YTag->horizontalPoints_.at(0)) / 2.0; DMReader_p pCdmReader, const CDMVariable* pVariable)
{
if (!pVariable)
throw CDMException("pVar is null");
YTag->distance_ = YTag->horizontalPoints_.at(1) - YTag->horizont if (!pCdmReader)
alPoints_.at(0); throw CDMException("pCdmReader is null");
if(YTag->distance_ < 0) std::shared_ptr<MetGmYTag> YTag;
throw CDMException("metgm is not supporting negative distanc
es on latitude axis");
}
} else {
}
return YTag; CoordinateSystem_cp cs = findCompleteCoordinateSystemFor(listCoordinateSyste
ms(pCdmReader), pVariable->getName());
if (cs && cs->isSimpleSpatialGridded() && cs->getGeoYAxis()) {
YTag = std::shared_ptr<MetGmYTag>(new MetGmYTag);
DataPtr data = pCdmReader->getScaledDataInUnit(cs->getGeoYAxis()->getNam
e(), "degree");
YTag->numberOfPoints_ = data->size();
YTag->extractHorizontalPoints(data);
YTag->center_ = (YTag->horizontalPoints_.back() + YTag->horizontalPoints
_.front()) / 2.0;
YTag->distance_ = YTag->horizontalPoints_.at(1) - YTag->horizontalPoints
_.front();
if (YTag->distance_ < 0)
throw CDMException("metgm is not supporting negative distances on la
titude axis");
} }
std::shared_ptr<MetGmXTag> MetGmHorizontalTag::createMetGmXTagForReading(con return YTag;
st std::shared_ptr<MetGmGroup3Ptr> pg3) }
{
std::shared_ptr<MetGmXTag> XTag = std::shared_ptr<MetGmXTag>(new MetGmXT
ag);
XTag->center_ = pg3->cx(); std::shared_ptr<MetGmXTag> MetGmHorizontalTag::createMetGmXTagForReading(const s
XTag->distance_ = pg3->dx(); td::shared_ptr<MetGmGroup3Ptr> pg3)
XTag->numberOfPoints_ = pg3->nx(); {
std::shared_ptr<MetGmXTag> XTag(new MetGmXTag);
double x0 = XTag->cx() - (XTag->nx() - 1) * XTag->dx() / 2.0; XTag->center_ = pg3->cx();
XTag->distance_ = pg3->dx();
XTag->numberOfPoints_ = pg3->nx();
for(size_t index = 0; index < XTag->nx(); ++index) { double x0 = XTag->cx() - (XTag->nx() - 1) * XTag->dx() / 2.0;
XTag->horizontalPoints_.push_back(x0 + index * XTag->dx());
}
return XTag; for (size_t index = 0; index < XTag->nx(); ++index) {
XTag->horizontalPoints_.push_back(x0 + index * XTag->dx());
} }
std::shared_ptr<MetGmYTag> MetGmHorizontalTag::createMetGmYTagForReading(con return XTag;
st std::shared_ptr<MetGmGroup3Ptr> pg3) }
{
std::shared_ptr<MetGmYTag> YTag = std::shared_ptr<MetGmYTag>(new MetGmYT
ag);
YTag->center_ = pg3->cy(); std::shared_ptr<MetGmYTag> MetGmHorizontalTag::createMetGmYTagForReading(const s
YTag->distance_ = pg3->dy(); td::shared_ptr<MetGmGroup3Ptr> pg3)
YTag->numberOfPoints_ = pg3->ny(); {
std::shared_ptr<MetGmYTag> YTag(new MetGmYTag);
double y0 = YTag->cy() - (YTag->ny() - 1) * YTag->dy() / 2.0; YTag->center_ = pg3->cy();
YTag->distance_ = pg3->dy();
YTag->numberOfPoints_ = pg3->ny();
for(size_t index = 0; index < YTag->ny(); ++index) { double y0 = YTag->cy() - (YTag->ny() - 1) * YTag->dy() / 2.0;
YTag->horizontalPoints_.push_back(y0 + index * YTag->dy());
}
return YTag; for (size_t index = 0; index < YTag->ny(); ++index) {
YTag->horizontalPoints_.push_back(y0 + index * YTag->dy());
} }
return YTag;
} }
} // namespace MetNoFimex
 End of changes. 20 change blocks. 
107 lines changed or deleted 71 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)