Gazebo Common

API Reference

5.6.0
gz/common/geospatial/Dem.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GZ_COMMON_GEOSPATIAL_DEM_HH_
18 #define GZ_COMMON_GEOSPATIAL_DEM_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include <gz/math/Vector3.hh>
25 #include <gz/math/Angle.hh>
26 #include <gz/math/SphericalCoordinates.hh>
27 
28 #include <gz/common/geospatial/Export.hh>
30 
31 #include <gz/utils/ImplPtr.hh>
32 
33 
34 namespace gz
35 {
36  namespace common
37  {
40  class GZ_COMMON_GEOSPATIAL_VISIBLE Dem : public HeightmapData
41  {
43  public: Dem();
44 
46  public: virtual ~Dem();
47 
53  const math::SphericalCoordinates &_worldSphericalCoordinates);
54 
58  public: int Load(const std::string &_filename = "");
59 
65  public: double Elevation(double _x, double _y);
66 
69  public: float MinElevation() const override;
70 
73  public: float MaxElevation() const override;
74 
80  public: bool GeoReferenceOrigin(gz::math::Angle &_latitude,
81  gz::math::Angle &_longitude) const;
82 
90  public: unsigned int Height() const override;
91 
99  public: unsigned int Width() const override;
100 
103  public: double WorldWidth() const;
104 
107  public: double WorldHeight() const;
108 
119  public: void FillHeightMap(const int _subSampling,
120  const unsigned int _vertSize,
121  const gz::math::Vector3d &_size,
122  const gz::math::Vector3d &_scale,
123  const bool _flipY,
124  std::vector<float> &_heights) const override;
125 
133  private: bool GeoReference(double _x, double _y,
134  gz::math::Angle &_latitude,
135  gz::math::Angle &_longitude) const;
136 
141  private: int LoadData();
142 
143  // Documentation inherited.
144  public: std::string Filename() const override;
145 
148  GZ_UTILS_IMPL_PTR(dataPtr)
149  };
150  }
151 }
152 #endif