Skip to content

Instantly share code, notes, and snippets.

@elmerehbi
Created August 7, 2020 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elmerehbi/8469bf3668259723ca248bb582bb85a2 to your computer and use it in GitHub Desktop.
Save elmerehbi/8469bf3668259723ca248bb582bb85a2 to your computer and use it in GitHub Desktop.
import enum
from dataclasses import dataclass
class EarthModel(enum.Enum):
WGS84 = "WGS84"
GRS80 = "GRS80"
@dataclass
class WGS84:
# https://earth-info.nga.mil/GandG/wgs84/gravitymod/egm2008/egm08_wgs84.html
# https://duckduckgo.com/?q=wgs84+constants&ia=web
a: float = 6378137.0 # m
b: float = 6356752.3142451794975639665996337 # 6356752.31424518 # m
earth_flat_coef: float = 1.0 / ((a - b) / a) # 298.257223563
e2: float = 2.0 / earth_flat_coef - 1.0 / (earth_flat_coef * earth_flat_coef)
e2inv: float = 1 - e2
ep2: float = e2 / (1 - e2)
@dataclass
class GRS80:
a = 6378137 # m
b = 6356752.314140 # m
earth_flat_coef = 1.0 / ((a - b) / a) # 298.257222101
e2 = 2.0 / earth_flat_coef - 1.0 / (earth_flat_coef * earth_flat_coef)
ep2 = e2 / (1 - e2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment