utm_util.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2014, 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_api.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  projPJ lat_lon_;
170  projPJ utm_north_[60];
171  projPJ utm_south_[60];
172 
173  mutable boost::mutex mutex_;
174  };
175  typedef boost::serialization::singleton<UtmData> UtmDataSingleton;
176 
178  };
179 }
180 
181 #endif // TRANSFORM_UTIL_UTM_UTIL_H_
void ToUtm(double latitude, double longitude, int &zone, char &band, double &easting, double &northing) const
Convert WGS84 latitude and longitude to UTM.
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.
void ToUtm(double latitude, double longitude, int &zone, char &band, double &easting, double &northing) const
Convert WGS84 latitude and longitude to UTM.
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.
The actual UTM conversion processing takes place in this helper class, which is a singleton due to th...
Definition: utm_util.h:116
Utility class for converting between latitude/longitude and UTM.
Definition: utm_util.h:62
const UtmData & utm_data_
Definition: utm_util.h:177
uint32_t GetZone(double longitude)
Given a longitude angle, get the UTM zone.
char GetBand(double latitude)
Given a latitude angle, get the UTM band letter.
boost::serialization::singleton< UtmData > UtmDataSingleton
Definition: utm_util.h:175


swri_transform_util
Author(s): Marc Alban
autogenerated on Tue Apr 6 2021 02:50:46