Skip to content

Commit 0a31b93

Browse files
mraspaudalexander-buerger-met-no
authored andcommitted
add oblique mercator and geostationary projections
1 parent f0c9d98 commit 0a31b93

8 files changed

Lines changed: 446 additions & 2 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Fimex, GeostationaryProjection.h
3+
*
4+
* (C) Copyright 2017, SMHI
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: May 12, 2017
24+
* Author: Martin Raspaud
25+
*/
26+
27+
#ifndef GEOSTATIONARYPROJECTION_H_
28+
#define GEOSTATIONARYPROJECTION_H_
29+
30+
#include "fimex/coordSys/ProjectionImpl.h"
31+
32+
namespace MetNoFimex
33+
{
34+
35+
/**
36+
* @headerfile fimex/coordSys/GeostationaryProjection.h
37+
*/
38+
class GeostationaryProjection: public MetNoFimex::ProjectionImpl
39+
{
40+
41+
public:
42+
GeostationaryProjection();
43+
virtual ~GeostationaryProjection() {}
44+
static bool acceptsProj4(const std::string& proj4Str);
45+
static std::vector<CDMAttribute> parametersFromProj4(const std::string& proj4);
46+
protected:
47+
GeostationaryProjection(std::string name) : ProjectionImpl(name, false) {}
48+
virtual std::ostream& getProj4ProjectionPart(std::ostream& oproj) const;
49+
};
50+
51+
}
52+
53+
54+
#endif /* GEOSTATIONARYPROJECTION_H_ */
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Fimex, ObliqueMercatorProjection.h
3+
*
4+
* (C) Copyright 2017, SMHI
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: May 12, 2017
24+
* Author: Martin Raspaud
25+
*/
26+
27+
#ifndef OBLIQUEMERCATORPROJECTION_H_
28+
#define OBLIQUEMERCATORPROJECTION_H_
29+
30+
#include "fimex/coordSys/ProjectionImpl.h"
31+
32+
namespace MetNoFimex
33+
{
34+
35+
/**
36+
* @headerfile fimex/coordSys/ObliqueMercatorProjection.h
37+
*/
38+
class ObliqueMercatorProjection: public MetNoFimex::ProjectionImpl
39+
{
40+
public:
41+
ObliqueMercatorProjection();
42+
virtual ~ObliqueMercatorProjection();
43+
static bool acceptsProj4(const std::string& proj4Str);
44+
static std::vector<CDMAttribute> parametersFromProj4(const std::string& proj4);
45+
protected:
46+
virtual std::ostream& getProj4ProjectionPart(std::ostream& oproj) const;
47+
48+
};
49+
50+
}
51+
52+
#endif /* OBLIQUEMERCATORPROJECTION_H_ */

src/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ libfimex_la_SOURCES = interpolation.c \
6565
coordSys/ProjectionImpl.cc \
6666
coordSys/AlbersConicalEqualAreaProjection.cc \
6767
coordSys/AzimuthalEquidistantProjection.cc \
68+
coordSys/GeostationaryProjection.cc \
6869
coordSys/LambertAzimuthalEqualAreaProjection.cc \
6970
coordSys/LambertConformalConicProjection.cc \
7071
coordSys/LambertCylindricalEqualAreaProjection.cc \
7172
coordSys/LatitudeLongitudeProjection.cc \
7273
coordSys/MercatorProjection.cc \
74+
coordSys/ObliqueMercatorProjection.cc \
7375
coordSys/OrthographicProjection.cc \
7476
coordSys/PolarStereographicProjection.cc \
7577
coordSys/RotatedLatitudeLongitudeProjection.cc \

src/Makefile.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,13 @@ am__libfimex_la_SOURCES_DIST = interpolation.c c_fimex.cc \
232232
coordSys/ProjectionImpl.cc \
233233
coordSys/AlbersConicalEqualAreaProjection.cc \
234234
coordSys/AzimuthalEquidistantProjection.cc \
235+
coordSys/GeostationaryProjection.cc \
235236
coordSys/LambertAzimuthalEqualAreaProjection.cc \
236237
coordSys/LambertConformalConicProjection.cc \
237238
coordSys/LambertCylindricalEqualAreaProjection.cc \
238239
coordSys/LatitudeLongitudeProjection.cc \
239240
coordSys/MercatorProjection.cc \
241+
coordSys/ObliqueMercatorProjection.cc \
240242
coordSys/OrthographicProjection.cc \
241243
coordSys/PolarStereographicProjection.cc \
242244
coordSys/RotatedLatitudeLongitudeProjection.cc \
@@ -395,11 +397,13 @@ am_libfimex_la_OBJECTS = interpolation.lo c_fimex.lo C_CDMReader.lo \
395397
coordSys/ProjectionImpl.lo \
396398
coordSys/AlbersConicalEqualAreaProjection.lo \
397399
coordSys/AzimuthalEquidistantProjection.lo \
400+
coordSys/GeostationaryProjection.lo \
398401
coordSys/LambertAzimuthalEqualAreaProjection.lo \
399402
coordSys/LambertConformalConicProjection.lo \
400403
coordSys/LambertCylindricalEqualAreaProjection.lo \
401404
coordSys/LatitudeLongitudeProjection.lo \
402405
coordSys/MercatorProjection.lo \
406+
coordSys/ObliqueMercatorProjection.lo \
403407
coordSys/OrthographicProjection.lo \
404408
coordSys/PolarStereographicProjection.lo \
405409
coordSys/RotatedLatitudeLongitudeProjection.lo \
@@ -746,11 +750,13 @@ libfimex_la_SOURCES = interpolation.c c_fimex.cc C_CDMReader.cc \
746750
coordSys/ProjectionImpl.cc \
747751
coordSys/AlbersConicalEqualAreaProjection.cc \
748752
coordSys/AzimuthalEquidistantProjection.cc \
753+
coordSys/GeostationaryProjection.cc \
749754
coordSys/LambertAzimuthalEqualAreaProjection.cc \
750755
coordSys/LambertConformalConicProjection.cc \
751756
coordSys/LambertCylindricalEqualAreaProjection.cc \
752757
coordSys/LatitudeLongitudeProjection.cc \
753758
coordSys/MercatorProjection.cc \
759+
coordSys/ObliqueMercatorProjection.cc \
754760
coordSys/OrthographicProjection.cc \
755761
coordSys/PolarStereographicProjection.cc \
756762
coordSys/RotatedLatitudeLongitudeProjection.cc \
@@ -901,6 +907,8 @@ coordSys/AlbersConicalEqualAreaProjection.lo: \
901907
coordSys/$(am__dirstamp) coordSys/$(DEPDIR)/$(am__dirstamp)
902908
coordSys/AzimuthalEquidistantProjection.lo: coordSys/$(am__dirstamp) \
903909
coordSys/$(DEPDIR)/$(am__dirstamp)
910+
coordSys/GeostationaryProjection.lo: coordSys/$(am__dirstamp) \
911+
coordSys/$(DEPDIR)/$(am__dirstamp)
904912
coordSys/LambertAzimuthalEqualAreaProjection.lo: \
905913
coordSys/$(am__dirstamp) coordSys/$(DEPDIR)/$(am__dirstamp)
906914
coordSys/LambertConformalConicProjection.lo: coordSys/$(am__dirstamp) \
@@ -911,6 +919,8 @@ coordSys/LatitudeLongitudeProjection.lo: coordSys/$(am__dirstamp) \
911919
coordSys/$(DEPDIR)/$(am__dirstamp)
912920
coordSys/MercatorProjection.lo: coordSys/$(am__dirstamp) \
913921
coordSys/$(DEPDIR)/$(am__dirstamp)
922+
coordSys/ObliqueMercatorProjection.lo: coordSys/$(am__dirstamp) \
923+
coordSys/$(DEPDIR)/$(am__dirstamp)
914924
coordSys/OrthographicProjection.lo: coordSys/$(am__dirstamp) \
915925
coordSys/$(DEPDIR)/$(am__dirstamp)
916926
coordSys/PolarStereographicProjection.lo: coordSys/$(am__dirstamp) \
@@ -1130,6 +1140,8 @@ mostlyclean-compile:
11301140
-rm -f coordSys/CoordinateAxis.lo
11311141
-rm -f coordSys/CoordinateSystem.$(OBJEXT)
11321142
-rm -f coordSys/CoordinateSystem.lo
1143+
-rm -f coordSys/GeostationaryProjection.$(OBJEXT)
1144+
-rm -f coordSys/GeostationaryProjection.lo
11331145
-rm -f coordSys/LambertAzimuthalEqualAreaProjection.$(OBJEXT)
11341146
-rm -f coordSys/LambertAzimuthalEqualAreaProjection.lo
11351147
-rm -f coordSys/LambertConformalConicProjection.$(OBJEXT)
@@ -1140,6 +1152,8 @@ mostlyclean-compile:
11401152
-rm -f coordSys/LatitudeLongitudeProjection.lo
11411153
-rm -f coordSys/MercatorProjection.$(OBJEXT)
11421154
-rm -f coordSys/MercatorProjection.lo
1155+
-rm -f coordSys/ObliqueMercatorProjection.$(OBJEXT)
1156+
-rm -f coordSys/ObliqueMercatorProjection.lo
11431157
-rm -f coordSys/OrthographicProjection.$(OBJEXT)
11441158
-rm -f coordSys/OrthographicProjection.lo
11451159
-rm -f coordSys/PolarStereographicProjection.$(OBJEXT)
@@ -1366,11 +1380,13 @@ distclean-compile:
13661380
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/CoordSysUtils.Plo@am__quote@
13671381
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/CoordinateAxis.Plo@am__quote@
13681382
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/CoordinateSystem.Plo@am__quote@
1383+
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/GeostationaryProjection.Plo@am__quote@
13691384
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/LambertAzimuthalEqualAreaProjection.Plo@am__quote@
13701385
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/LambertConformalConicProjection.Plo@am__quote@
13711386
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/LambertCylindricalEqualAreaProjection.Plo@am__quote@
13721387
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/LatitudeLongitudeProjection.Plo@am__quote@
13731388
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/MercatorProjection.Plo@am__quote@
1389+
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/ObliqueMercatorProjection.Plo@am__quote@
13741390
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/OrthographicProjection.Plo@am__quote@
13751391
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/PolarStereographicProjection.Plo@am__quote@
13761392
@AMDEP_TRUE@@am__include@ @am__quote@coordSys/$(DEPDIR)/Projection.Plo@am__quote@
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Fimex, GeostationaryProjection.cc
3+
*
4+
* (C) Copyright 2011, 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: May 12, 2017
24+
* Author: Martin Raspaud
25+
*/
26+
27+
#include "fimex/coordSys/GeostationaryProjection.h"
28+
#include <boost/regex.hpp>
29+
#include "fimex/Utils.h"
30+
31+
namespace MetNoFimex
32+
{
33+
34+
using namespace std;
35+
36+
GeostationaryProjection::GeostationaryProjection()
37+
: ProjectionImpl("geostationary", false)
38+
{
39+
}
40+
41+
bool GeostationaryProjection::acceptsProj4(const std::string& proj4Str)
42+
{
43+
return proj4ProjectionMatchesName(proj4Str, "geos");
44+
}
45+
46+
std::vector<CDMAttribute> GeostationaryProjection::parametersFromProj4(const std::string& proj4Str)
47+
{
48+
vector<CDMAttribute> attrs;
49+
if (!acceptsProj4(proj4Str)) return attrs;
50+
51+
attrs.push_back(CDMAttribute("grid_mapping_name", "geostationary"));
52+
53+
boost::smatch what;
54+
double lon0 = 0.;
55+
if (boost::regex_search(proj4Str, what, boost::regex("\\+lon_0=(\\S+)"))) {
56+
lon0 = string2type<double>(what[1].str());
57+
}
58+
attrs.push_back(CDMAttribute("longitude_of_projection_origin", lon0));
59+
60+
double lat0 = 0.;
61+
if (boost::regex_search(proj4Str, what, boost::regex("\\+lat_0=(\\S+)"))) {
62+
lat0 = string2type<double>(what[1].str());
63+
}
64+
attrs.push_back(CDMAttribute("latitude_of_projection_origin", lat0));
65+
66+
double h = 0.;
67+
if (boost::regex_search(proj4Str, what, boost::regex("\\+h=(\\S+)"))) {
68+
h = string2type<double>(what[1].str());
69+
}
70+
attrs.push_back(CDMAttribute("perspective_point_height", h));
71+
72+
string sweep = "y";
73+
if (boost::regex_search(proj4Str, what, boost::regex("\\+sweep=(\\S+)"))) {
74+
sweep = what[1].str();
75+
}
76+
attrs.push_back(CDMAttribute("sweep_axis", sweep));
77+
78+
proj4GetEarthAttributes(proj4Str, attrs);
79+
attrs.push_back(CDMAttribute("proj4", proj4Str));
80+
return attrs;
81+
}
82+
83+
std::ostream& GeostationaryProjection::getProj4ProjectionPart(std::ostream& oproj) const
84+
{
85+
oproj << "+proj=geos";
86+
addParameterToStream(oproj, "longitude_of_projection_origin", " +lon_0=");
87+
addParameterToStream(oproj, "latitude_of_projection_origin", " +lat_0=");
88+
addParameterToStream(oproj, "perspective_point_height", " +h=");
89+
addParameterToStream(oproj, "sweep_angle_axis", " +sweep=");
90+
91+
return oproj;
92+
}
93+
94+
}

0 commit comments

Comments
 (0)