Commit 71d1ea27 authored by xueyimeng's avatar xueyimeng

取消对GeographicLib的依赖

parent f312d14a
<?xml version="1.0" encoding="UTF-8"?>
<module type="CPP_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<module classpath="CMake" type="CPP_MODULE" version="4" />
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$/cloud_common">
<contentRoot DIR="$PROJECT_DIR$" />
</component>
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
......
project(CloudCommon)
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_BUILD_TYPE Release)
#ADD_COMPILE_OPTIONS(-std=c++14 )
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
......
#pragma once
#include <memory>
#include <cmath>
#include <GeographicLib/LocalCartesian.hpp>
#include <Eigen/Dense>
namespace jf {
class LatLonCartesian {
public:
using Ptr = std::shared_ptr<LatLonCartesian>;
using ConstPtr = std::shared_ptr<const LatLonCartesian>;
LatLonCartesian()
: geographic_local_(std::numeric_limits<double>::max(),
std::numeric_limits<double>::max(),
std::numeric_limits<double>::max()) {}
LatLonCartesian(double lat, double lng, double h)
: geographic_local_(lat, lng, h) {}
inline bool isOriginSet() const {
return std::abs(geographic_local_.LatitudeOrigin()) < 360.0;
}
inline void setOrigin(double lat0, double lon0, double h0) {
geographic_local_.Reset(lat0, lon0, h0);
}
inline Eigen::Vector3d getOrigin() const {
return {geographic_local_.LatitudeOrigin(),
geographic_local_.LongitudeOrigin(),
geographic_local_.HeightOrigin()};
}
/**
* Given another lat lon h, calculate it's coordinates in the local ENU
* coordinate system of origin
* @param lat
* @param lon
* @param h
* @return X, Y, Z
*/
inline Eigen::Vector3d LocalXYZ(double lat, double lon, double h) const {
Eigen::Vector3d local;
geographic_local_.Forward(lat, lon, h, local[0], local[1], local[2]);
return local;
}
/**
* Given another X, Y, Z, calculate it's coordinates in the LatLon
* coordinate system.
* @param X
* @param Y
* @param Z
* @return lat, lon, height
*/
inline Eigen::Vector3d LatLonHeight(double x, double y, double z) const {
Eigen::Vector3d latlon;
// not our navigation is north east earth, but navigation in GeographicLib
// is east north sky
geographic_local_.Reverse(x, y, z, latlon[0], latlon[1], latlon[2]);
return latlon;
}
inline double getDistance(double lat, double lon, double h) const {
Eigen::Vector3d local = LocalXYZ(lat, lon, h);
return local.norm();
}
/**
* Given another lat lon position, calculate the relative rotation its NED
* system and the origin's NED system
* @param lat
* @param lon
* @return
*/
inline Eigen::Matrix3d C_n_no(double lat, double lon) const {
return (Eigen::AngleAxisd(
(lat - geographic_local_.LatitudeOrigin()) * M_PI / 180.0,
Eigen::Vector3d::UnitY()) *
Eigen::AngleAxisd(
(geographic_local_.LongitudeOrigin() - lon) * M_PI / 180.0,
Eigen::Vector3d::UnitX()))
.toRotationMatrix();
}
/**
* Given another lat lon position, calculate the relative rotation its NED
* system and the origin's NED system
* @param lat
* @param lon
* @return
*/
inline Eigen::Matrix3d C_no_n(double lat, double lon) const {
return (Eigen::AngleAxisd(
(lon - geographic_local_.LongitudeOrigin()) * M_PI / 180.0,
Eigen::Vector3d::UnitX()) *
Eigen::AngleAxisd(
(geographic_local_.LatitudeOrigin() - lat) * M_PI / 180.0,
Eigen::Vector3d::UnitY()))
.toRotationMatrix();
}
protected:
GeographicLib::LocalCartesian geographic_local_;
};
inline double getDistance(const double lat1, const double lon1, const double h1,
const double lat2, const double lon2, const double h2) {
LatLonCartesian lat_lon_cartersian(lat1, lon1, h1);
return lat_lon_cartersian.getDistance(lat2, lon2, h2);
}
} // namespace jf
\ No newline at end of file
#include "track.h"
#include "ogr_spatialref.h"
#include "utility/lat_lon_cartersian.hpp"
//#include "utility/lat_lon_cartersian.hpp"
#include "utility/Utility.h"
#include <fstream>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment