Skip to content

Commit

Permalink
add oblique mercator and geostationary projections
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud authored and alexander-buerger-met-no committed May 24, 2017
1 parent f0c9d98 commit 0a31b93
Show file tree
Hide file tree
Showing 8 changed files with 446 additions and 2 deletions.
54 changes: 54 additions & 0 deletions include/fimex/coordSys/GeostationaryProjection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Fimex, GeostationaryProjection.h
*
* (C) Copyright 2017, SMHI
*
* Project Info: https://wiki.met.no/fimex/start
*
* 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
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* Created on: May 12, 2017
* Author: Martin Raspaud
*/

#ifndef GEOSTATIONARYPROJECTION_H_
#define GEOSTATIONARYPROJECTION_H_

#include "fimex/coordSys/ProjectionImpl.h"

namespace MetNoFimex
{

/**
* @headerfile fimex/coordSys/GeostationaryProjection.h
*/
class GeostationaryProjection: public MetNoFimex::ProjectionImpl
{

public:
GeostationaryProjection();
virtual ~GeostationaryProjection() {}
static bool acceptsProj4(const std::string& proj4Str);
static std::vector<CDMAttribute> parametersFromProj4(const std::string& proj4);
protected:
GeostationaryProjection(std::string name) : ProjectionImpl(name, false) {}
virtual std::ostream& getProj4ProjectionPart(std::ostream& oproj) const;
};

}


#endif /* GEOSTATIONARYPROJECTION_H_ */
52 changes: 52 additions & 0 deletions include/fimex/coordSys/ObliqueMercatorProjection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Fimex, ObliqueMercatorProjection.h
*
* (C) Copyright 2017, SMHI
*
* Project Info: https://wiki.met.no/fimex/start
*
* 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
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* Created on: May 12, 2017
* Author: Martin Raspaud
*/

#ifndef OBLIQUEMERCATORPROJECTION_H_
#define OBLIQUEMERCATORPROJECTION_H_

#include "fimex/coordSys/ProjectionImpl.h"

namespace MetNoFimex
{

/**
* @headerfile fimex/coordSys/ObliqueMercatorProjection.h
*/
class ObliqueMercatorProjection: public MetNoFimex::ProjectionImpl
{
public:
ObliqueMercatorProjection();
virtual ~ObliqueMercatorProjection();
static bool acceptsProj4(const std::string& proj4Str);
static std::vector<CDMAttribute> parametersFromProj4(const std::string& proj4);
protected:
virtual std::ostream& getProj4ProjectionPart(std::ostream& oproj) const;

};

}

#endif /* OBLIQUEMERCATORPROJECTION_H_ */
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ libfimex_la_SOURCES = interpolation.c \
coordSys/ProjectionImpl.cc \
coordSys/AlbersConicalEqualAreaProjection.cc \
coordSys/AzimuthalEquidistantProjection.cc \
coordSys/GeostationaryProjection.cc \
coordSys/LambertAzimuthalEqualAreaProjection.cc \
coordSys/LambertConformalConicProjection.cc \
coordSys/LambertCylindricalEqualAreaProjection.cc \
coordSys/LatitudeLongitudeProjection.cc \
coordSys/MercatorProjection.cc \
coordSys/ObliqueMercatorProjection.cc \
coordSys/OrthographicProjection.cc \
coordSys/PolarStereographicProjection.cc \
coordSys/RotatedLatitudeLongitudeProjection.cc \
Expand Down
16 changes: 16 additions & 0 deletions src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,13 @@ am__libfimex_la_SOURCES_DIST = interpolation.c c_fimex.cc \
coordSys/ProjectionImpl.cc \
coordSys/AlbersConicalEqualAreaProjection.cc \
coordSys/AzimuthalEquidistantProjection.cc \
coordSys/GeostationaryProjection.cc \
coordSys/LambertAzimuthalEqualAreaProjection.cc \
coordSys/LambertConformalConicProjection.cc \
coordSys/LambertCylindricalEqualAreaProjection.cc \
coordSys/LatitudeLongitudeProjection.cc \
coordSys/MercatorProjection.cc \
coordSys/ObliqueMercatorProjection.cc \
coordSys/OrthographicProjection.cc \
coordSys/PolarStereographicProjection.cc \
coordSys/RotatedLatitudeLongitudeProjection.cc \
Expand Down Expand Up @@ -395,11 +397,13 @@ am_libfimex_la_OBJECTS = interpolation.lo c_fimex.lo C_CDMReader.lo \
coordSys/ProjectionImpl.lo \
coordSys/AlbersConicalEqualAreaProjection.lo \
coordSys/AzimuthalEquidistantProjection.lo \
coordSys/GeostationaryProjection.lo \
coordSys/LambertAzimuthalEqualAreaProjection.lo \
coordSys/LambertConformalConicProjection.lo \
coordSys/LambertCylindricalEqualAreaProjection.lo \
coordSys/LatitudeLongitudeProjection.lo \
coordSys/MercatorProjection.lo \
coordSys/ObliqueMercatorProjection.lo \
coordSys/OrthographicProjection.lo \
coordSys/PolarStereographicProjection.lo \
coordSys/RotatedLatitudeLongitudeProjection.lo \
Expand Down Expand Up @@ -746,11 +750,13 @@ libfimex_la_SOURCES = interpolation.c c_fimex.cc C_CDMReader.cc \
coordSys/ProjectionImpl.cc \
coordSys/AlbersConicalEqualAreaProjection.cc \
coordSys/AzimuthalEquidistantProjection.cc \
coordSys/GeostationaryProjection.cc \
coordSys/LambertAzimuthalEqualAreaProjection.cc \
coordSys/LambertConformalConicProjection.cc \
coordSys/LambertCylindricalEqualAreaProjection.cc \
coordSys/LatitudeLongitudeProjection.cc \
coordSys/MercatorProjection.cc \
coordSys/ObliqueMercatorProjection.cc \
coordSys/OrthographicProjection.cc \
coordSys/PolarStereographicProjection.cc \
coordSys/RotatedLatitudeLongitudeProjection.cc \
Expand Down Expand Up @@ -901,6 +907,8 @@ coordSys/AlbersConicalEqualAreaProjection.lo: \
coordSys/$(am__dirstamp) coordSys/$(DEPDIR)/$(am__dirstamp)
coordSys/AzimuthalEquidistantProjection.lo: coordSys/$(am__dirstamp) \
coordSys/$(DEPDIR)/$(am__dirstamp)
coordSys/GeostationaryProjection.lo: coordSys/$(am__dirstamp) \
coordSys/$(DEPDIR)/$(am__dirstamp)
coordSys/LambertAzimuthalEqualAreaProjection.lo: \
coordSys/$(am__dirstamp) coordSys/$(DEPDIR)/$(am__dirstamp)
coordSys/LambertConformalConicProjection.lo: coordSys/$(am__dirstamp) \
Expand All @@ -911,6 +919,8 @@ coordSys/LatitudeLongitudeProjection.lo: coordSys/$(am__dirstamp) \
coordSys/$(DEPDIR)/$(am__dirstamp)
coordSys/MercatorProjection.lo: coordSys/$(am__dirstamp) \
coordSys/$(DEPDIR)/$(am__dirstamp)
coordSys/ObliqueMercatorProjection.lo: coordSys/$(am__dirstamp) \
coordSys/$(DEPDIR)/$(am__dirstamp)
coordSys/OrthographicProjection.lo: coordSys/$(am__dirstamp) \
coordSys/$(DEPDIR)/$(am__dirstamp)
coordSys/PolarStereographicProjection.lo: coordSys/$(am__dirstamp) \
Expand Down Expand Up @@ -1130,6 +1140,8 @@ mostlyclean-compile:
-rm -f coordSys/CoordinateAxis.lo
-rm -f coordSys/CoordinateSystem.$(OBJEXT)
-rm -f coordSys/CoordinateSystem.lo
-rm -f coordSys/GeostationaryProjection.$(OBJEXT)
-rm -f coordSys/GeostationaryProjection.lo
-rm -f coordSys/LambertAzimuthalEqualAreaProjection.$(OBJEXT)
-rm -f coordSys/LambertAzimuthalEqualAreaProjection.lo
-rm -f coordSys/LambertConformalConicProjection.$(OBJEXT)
Expand All @@ -1140,6 +1152,8 @@ mostlyclean-compile:
-rm -f coordSys/LatitudeLongitudeProjection.lo
-rm -f coordSys/MercatorProjection.$(OBJEXT)
-rm -f coordSys/MercatorProjection.lo
-rm -f coordSys/ObliqueMercatorProjection.$(OBJEXT)
-rm -f coordSys/ObliqueMercatorProjection.lo
-rm -f coordSys/OrthographicProjection.$(OBJEXT)
-rm -f coordSys/OrthographicProjection.lo
-rm -f coordSys/PolarStereographicProjection.$(OBJEXT)
Expand Down Expand Up @@ -1366,11 +1380,13 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/CoordSysUtils.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/CoordinateAxis.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/CoordinateSystem.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/GeostationaryProjection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/LambertAzimuthalEqualAreaProjection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/LambertConformalConicProjection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/LambertCylindricalEqualAreaProjection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/LatitudeLongitudeProjection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/MercatorProjection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/ObliqueMercatorProjection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/OrthographicProjection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/PolarStereographicProjection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/Projection.Plo@am__quote@
Expand Down
94 changes: 94 additions & 0 deletions src/coordSys/GeostationaryProjection.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Fimex, GeostationaryProjection.cc
*
* (C) Copyright 2011, met.no
*
* Project Info: https://wiki.met.no/fimex/start
*
* 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
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* Created on: May 12, 2017
* Author: Martin Raspaud
*/

#include "fimex/coordSys/GeostationaryProjection.h"
#include <boost/regex.hpp>
#include "fimex/Utils.h"

namespace MetNoFimex
{

using namespace std;

GeostationaryProjection::GeostationaryProjection()
: ProjectionImpl("geostationary", false)
{
}

bool GeostationaryProjection::acceptsProj4(const std::string& proj4Str)
{
return proj4ProjectionMatchesName(proj4Str, "geos");
}

std::vector<CDMAttribute> GeostationaryProjection::parametersFromProj4(const std::string& proj4Str)
{
vector<CDMAttribute> attrs;
if (!acceptsProj4(proj4Str)) return attrs;

attrs.push_back(CDMAttribute("grid_mapping_name", "geostationary"));

boost::smatch what;
double lon0 = 0.;
if (boost::regex_search(proj4Str, what, boost::regex("\\+lon_0=(\\S+)"))) {
lon0 = string2type<double>(what[1].str());
}
attrs.push_back(CDMAttribute("longitude_of_projection_origin", lon0));

double lat0 = 0.;
if (boost::regex_search(proj4Str, what, boost::regex("\\+lat_0=(\\S+)"))) {
lat0 = string2type<double>(what[1].str());
}
attrs.push_back(CDMAttribute("latitude_of_projection_origin", lat0));

double h = 0.;
if (boost::regex_search(proj4Str, what, boost::regex("\\+h=(\\S+)"))) {
h = string2type<double>(what[1].str());
}
attrs.push_back(CDMAttribute("perspective_point_height", h));

string sweep = "y";
if (boost::regex_search(proj4Str, what, boost::regex("\\+sweep=(\\S+)"))) {
sweep = what[1].str();
}
attrs.push_back(CDMAttribute("sweep_axis", sweep));

proj4GetEarthAttributes(proj4Str, attrs);
attrs.push_back(CDMAttribute("proj4", proj4Str));
return attrs;
}

std::ostream& GeostationaryProjection::getProj4ProjectionPart(std::ostream& oproj) const
{
oproj << "+proj=geos";
addParameterToStream(oproj, "longitude_of_projection_origin", " +lon_0=");
addParameterToStream(oproj, "latitude_of_projection_origin", " +lat_0=");
addParameterToStream(oproj, "perspective_point_height", " +h=");
addParameterToStream(oproj, "sweep_angle_axis", " +sweep=");

return oproj;
}

}
Loading

0 comments on commit 0a31b93

Please sign in to comment.