PISM, A Parallel Ice Sheet Model
2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
src
util
LonLatCalculator.hh
Go to the documentation of this file.
1
/* Copyright (C) 2025 PISM Authors
2
*
3
* This file is part of PISM.
4
*
5
* PISM is free software; you can redistribute it and/or modify it under the
6
* terms of the GNU General Public License as published by the Free Software
7
* Foundation; either version 3 of the License, or (at your option) any later
8
* version.
9
*
10
* PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13
* details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with PISM; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
*/
19
20
#ifndef PISM_LONLATCALCULATOR_H
21
#define PISM_LONLATCALCULATOR_H
22
23
#include <array>
24
25
#include "pism/util/Proj.hh"
26
27
namespace
pism
{
28
29
/*!
30
* Utility class converting `x,y` coordinates in a projection to a `lon,lat` pair.
31
*
32
* Requires the `PROJ` library.
33
*/
34
class
LonLatCalculator
{
35
public
:
36
LonLatCalculator
(
const
std::string &proj_string)
37
:
m_coordinate_mapping
(proj_string,
"EPSG:4326"
) {
38
}
39
40
std::array<double, 2>
lonlat
(
double
x,
double
y) {
41
PJ_COORD out = proj_trans(
m_coordinate_mapping
, PJ_FWD, proj_coord(x, y, 0, 0));
42
43
// longitude: lambda
44
// latitude: phi
45
return
{ out.lp.lam, out.lp.phi };
46
}
47
48
private
:
49
Proj
m_coordinate_mapping
;
50
};
51
52
}
// namespace pism
53
54
#endif
/* PISM_LONLATCALCULATOR_H */
pism::LonLatCalculator::m_coordinate_mapping
Proj m_coordinate_mapping
Definition
LonLatCalculator.hh:49
pism::LonLatCalculator::LonLatCalculator
LonLatCalculator(const std::string &proj_string)
Definition
LonLatCalculator.hh:36
pism::LonLatCalculator::lonlat
std::array< double, 2 > lonlat(double x, double y)
Definition
LonLatCalculator.hh:40
pism::LonLatCalculator
Definition
LonLatCalculator.hh:34
pism::Proj
A wrapper for PJ that makes sure pj_destroy is called.
Definition
Proj.hh:32
pism
Definition
AgeColumnSystem.cc:23
Generated by
1.9.8