Published
Edited
Feb 18, 2020
1 fork
4 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mu0 = Math.radians(start[0])
Insert cell
m_per_deg_lat = 111132.92 - 559.82 * Math.cos(2*mu0) + 1.175 * Math.cos(4*mu0) -0.0023 * Math.cos(6*mu0)

Insert cell
m_per_deg_long = 111412.84 * Math.cos(mu0) -93.5* Math.cos(3*mu0) + 0.118 * Math.cos(5*mu0)
Insert cell
Insert cell
Insert cell
function getLatLong(flatearth_pos, lat_long_origin, rotation, href) {
// ellipsoid planet defined by flattening (WGS84).
//var f = 1/298.257223563;
// planetary equatorial radius (WGS84)
//var Re = 6378137;
var psi = Math.radians(rotation)
var x = flatearth_pos[0]
var y = flatearth_pos[1]
var z = flatearth_pos[2]
//var mu0 = Math.radians(lat_long_origin[0])
//var m_per_deg_lat = 111132.92 - 559.82 * Math.cos(2*mu0) + 1.175 * Math.cos(4*mu0) -0.0023 * Math.cos(6*mu0)
//var m_per_deg_long = 111412.84 * Math.cos(mu0) -93.5* Math.cos(3*mu0) + 0.118 * Math.cos(5*mu0)
//rotate
//begin by transforming the flat Earth x and y coordinates to North and East coordinates, through a simple rotation.
// (These will still be in meters.)
var N = Math.cos(psi) * y - Math.sin(psi) * x
// sin(psi) * 0 + cos(psi) * 200
var E = Math.sin(psi) * y + Math.cos(psi) * x
var Ndeg = N / m_per_deg_lat
var Edeg = E / m_per_deg_long
//translate
var lat = lat_long_origin[0] + Ndeg
var long = lat_long_origin[1] + Edeg
var alt = href + z
//return [[lat,long, alt],[lat0,long0],[x,y,z],[N,E],[m_per_deg_lat,m_per_deg_long],[Ndeg,Edeg]]
return [lat,long,alt]
}
Insert cell
Insert cell
function getXYZfromLLA(LLA, lat_long_origin, rotation, href) {
var Ndeg = LLA[0] - lat_long_origin[0]
var Edeg = LLA[1] - lat_long_origin[1]
var psi = Math.radians(-rotation)
// calculate meter coordinates
var N = Ndeg * m_per_deg_lat
var E = Edeg * m_per_deg_long
//rotate:
var y = Math.cos(psi) * N - Math.sin(psi) * E
var x = Math.sin(psi) * N + Math.cos(psi) * E
var z = LLA[2] - href
return [x,y,z]

}
Insert cell
Insert cell
Insert cell
LLresult = getLatLong([50,200,10], start, rotation, href)
Insert cell
Insert cell
Insert cell
Insert cell
XYresult = getXYZfromLLA(testLLA,start,rotation, href)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
show(XYdata)
Insert cell
Insert cell
trackLLA = trackXYZ.map(function(point) {
var LLA = getLatLong(point, start, rotation, href)
return LLA
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3 = require("d3@5")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more