I'm trying to generate an airport runways digram, something like this:
Each airport has a list of runways represented as follows:
const runways = [
{
identifier1: "110L",
identifier2: "28R",
length: 3107,
width: 75,
latitude1: 37.66247544,
longitude1: -122.12726156,
latitude2: 37.65822686,
longitude2: -122.11795339,
},
{
identifier1: "10R",
identifier2: "28L",
length: 5694,
width: 150,
latitude1: 37.66204453,
longitude1: -122.12979078,
latitude2: 37.65426,
longitude2: -122.11273375,
},
];
As you can see each runway has starting and ending geo points. For visuals I'm using svg-airports, the above example of the runways is represented by this:
<airport-diagram width="200" height="200">
<airport-runway
length-ft="3107"
true-heading="119"
offset-angle="29"
offset-x="300"
offset-y="1000"
>
<runway-id name="10L" pattern="left"></runway-id>
<runway-id name="28R" pattern="right"></runway-id>
</airport-runway>
<airport-runway
length-ft="5694"
true-heading="119"
offset-angle="29"
offset-x="300"
offset-y="-1000"
>
<runway-id name="10R" pattern="right"></runway-id>
<runway-id name="28L" pattern="left"></runway-id>
</airport-runway>
</airport-diagram>
As you can see that each runway has the following values
- length
- true-heading
- offset-angle
- offset-x
- offset-y
I'm able to provide the length as I already have that info from my airport
and I'm calculating the true-heading (bearing) as follows:
function radians(n) {
return n * (Math.PI / 180);
}
function degrees(n) {
return n * (180 / Math.PI);
}
function getBearing(startLat, startLong, endLat, endLong) {
startLat = radians(startLat);
startLong = radians(startLong);
endLat = radians(endLat);
endLong = radians(endLong);
var dLong = endLong - startLong;
var dPhi = Math.log(
Math.tan(endLat / 2.0 + Math.PI / 4.0) /
Math.tan(startLat / 2.0 + Math.PI / 4.0)
);
if (Math.abs(dLong) > Math.PI) {
if (dLong > 0.0) dLong = -(2.0 * Math.PI - dLong);
else dLong = 2.0 * Math.PI + dLong;
}
return (degrees(Math.atan2(dLong, dPhi)) + 180.0) % 180.0;
}
The question is, can I calculate the offset-angle
, offset-x
, and offset-y
based on the geo coordinates between the runways ?
P.S: the offset values are in feet.