utm_util.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2023, Southwest Research Institute® (SwRI®)
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 // *****************************************************************************
29 
30 #ifndef TRANSFORM_UTIL_UTM_UTIL_H_
31 #define TRANSFORM_UTIL_UTM_UTIL_H_
32 
33 #include <stdint.h>
34 
35 #include <boost/serialization/singleton.hpp>
36 #include <boost/thread/mutex.hpp>
37 
38 #include <proj.h>
39 
40 namespace swri_transform_util
41 {
47  uint32_t GetZone(double longitude);
48 
54  char GetBand(double latitude);
55 
62  class UtmUtil
63  {
64  public:
65  UtmUtil();
66 
77  void ToUtm(
78  double latitude, double longitude,
79  int& zone, char& band, double& easting, double& northing) const;
80 
89  void ToUtm(
90  double latitude, double longitude,
91  double& easting, double& northing) const;
92 
103  void ToLatLon(
104  int zone, char band, double easting, double northing,
105  double& latitude, double& longitude) const;
106 
107  private:
116  class UtmData
117  {
118  public:
119  ~UtmData();
120 
131  void ToUtm(
132  double latitude, double longitude,
133  int& zone, char& band, double& easting, double& northing) const;
134 
143  void ToUtm(
144  double latitude, double longitude,
145  double& easting, double& northing) const;
146 
157  void ToLatLon(
158  int zone, char band, double easting, double northing,
159  double& latitude, double& longitude) const;
160 
161 #if (BOOST_VERSION / 100 % 1000) >= 65 && (BOOST_VERSION / 100 % 1000) < 69
162  friend class boost::serialization::singleton<swri_transform_util::UtmUtil::UtmData>;
163 #else
164  friend class boost::serialization::detail::singleton_wrapper<swri_transform_util::UtmUtil::UtmData>;
165 #endif
166  private:
167  UtmData();
168 
169  PJ *P_ll_north_[60];
170  PJ *P_ll_south_[60];
171 
172  mutable boost::mutex mutex_;
173  };
174  typedef boost::serialization::singleton<UtmData> UtmDataSingleton;
175 
177  };
178 }
179 
180 #endif // TRANSFORM_UTIL_UTM_UTIL_H_
swri_transform_util::UtmUtil::ToLatLon
void ToLatLon(int zone, char band, double easting, double northing, double &latitude, double &longitude) const
Convert UTM easting and northing to WGS84 latitude and longitude.
swri_transform_util::UtmUtil::UtmData::ToLatLon
void ToLatLon(int zone, char band, double easting, double northing, double &latitude, double &longitude) const
Convert UTM easting and northing to WGS84 latitude and longitude.
swri_transform_util::UtmUtil
Utility class for converting between latitude/longitude and UTM.
Definition: utm_util.h:62
swri_transform_util::UtmUtil::ToUtm
void ToUtm(double latitude, double longitude, int &zone, char &band, double &easting, double &northing) const
Convert WGS84 latitude and longitude to UTM.
swri_transform_util::GetZone
uint32_t GetZone(double longitude)
Given a longitude angle, get the UTM zone.
swri_transform_util::UtmUtil::UtmData::mutex_
boost::mutex mutex_
Definition: utm_util.h:172
swri_transform_util::UtmUtil::UtmData::P_ll_north_
PJ * P_ll_north_[60]
Definition: utm_util.h:169
swri_transform_util::UtmUtil::UtmData::ToUtm
void ToUtm(double latitude, double longitude, int &zone, char &band, double &easting, double &northing) const
Convert WGS84 latitude and longitude to UTM.
swri_transform_util::UtmUtil::UtmData::P_ll_south_
PJ * P_ll_south_[60]
Definition: utm_util.h:170
swri_transform_util::GetBand
char GetBand(double latitude)
Given a latitude angle, get the UTM band letter.
swri_transform_util
Definition: earth_constants.h:33
swri_transform_util::UtmUtil::UtmUtil
UtmUtil()
swri_transform_util::UtmUtil::UtmDataSingleton
boost::serialization::singleton< UtmData > UtmDataSingleton
Definition: utm_util.h:174
swri_transform_util::UtmUtil::UtmData
The actual UTM conversion processing takes place in this helper class, which is a singleton due to th...
Definition: utm_util.h:116
swri_transform_util::UtmUtil::UtmData::~UtmData
~UtmData()
swri_transform_util::UtmUtil::utm_data_
const UtmData & utm_data_
Definition: utm_util.h:176


swri_transform_util
Author(s): Marc Alban
autogenerated on Fri Aug 2 2024 08:39:26