mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:50:06 +00:00 
			
		
		
		
	Utility function to get geographic coordinate from i and j
This commit is contained in:
		
							parent
							
								
									5d828b0819
								
							
						
					
					
						commit
						8ae973c4cb
					
				
					 2 changed files with 34 additions and 0 deletions
				
			
		|  | @ -1,6 +1,8 @@ | |||
| #include <scwx/qt/util/geographic_lib.hpp> | ||||
| #include <scwx/util/logger.hpp> | ||||
| 
 | ||||
| #include <numbers> | ||||
| 
 | ||||
| #include <GeographicLib/Gnomonic.hpp> | ||||
| #include <geos/algorithm/PointLocation.h> | ||||
| #include <geos/geom/CoordinateSequence.h> | ||||
|  | @ -90,6 +92,25 @@ GetAngle(double lat1, double lon1, double lat2, double lon2) | |||
|    return units::angle::degrees<double> {azi1}; | ||||
| } | ||||
| 
 | ||||
| common::Coordinate GetCoordinate(const common::Coordinate& center, | ||||
|                                  units::meters<double>     i, | ||||
|                                  units::meters<double>     j) | ||||
| { | ||||
|    // Calculate polar coordinates based on i and j
 | ||||
|    const double angle = | ||||
|       std::atan2(i.value(), j.value()) * 180.0 / std::numbers::pi; | ||||
|    const double range = | ||||
|       std::sqrt(i.value() * i.value() + j.value() * j.value()); | ||||
| 
 | ||||
|    double latitude; | ||||
|    double longitude; | ||||
| 
 | ||||
|    DefaultGeodesic().Direct( | ||||
|       center.latitude_, center.longitude_, angle, range, latitude, longitude); | ||||
| 
 | ||||
|    return {latitude, longitude}; | ||||
| } | ||||
| 
 | ||||
| units::length::meters<double> | ||||
| GetDistance(double lat1, double lon1, double lat2, double lon2) | ||||
| { | ||||
|  |  | |||
|  | @ -49,6 +49,19 @@ bool AreaContainsPoint(const std::vector<common::Coordinate>& area, | |||
| units::angle::degrees<double> | ||||
| GetAngle(double lat1, double lon1, double lat2, double lon2); | ||||
| 
 | ||||
| /**
 | ||||
|  * Get a coordinate from an (i, j) offset. | ||||
|  * | ||||
|  * @param [in] center The center coordinate from which i and j are offset | ||||
|  * @param [in] i The easting offset in meters | ||||
|  * @param [in] j The northing offset in meters | ||||
|  *  | ||||
|  * @return offset coordinate | ||||
|  */ | ||||
| common::Coordinate GetCoordinate(const common::Coordinate& center, | ||||
|                                  units::meters<double>     i, | ||||
|                                  units::meters<double>     j); | ||||
| 
 | ||||
| /**
 | ||||
|  * Get the distance between two points. | ||||
|  * | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat