Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
recalculate: function(data){
if(this.isLocked()){return}
this.mutexLock()
Object.extend(data, {
"currentUniversalTime": this.adjustUniversalTime(data['t.universalTime']),
"vesselBody": data['v.body'],
"targetBody": data['tar.o.orbitingBody'],
"vesselCurrentPosition": { "relativePosition": null },
"targetCurrentPosition": { "relativePosition": null },
})
this.getPositionsAndRecalculate(data)
},
formatTargetVessel: function(positionData, formattedData){
if(!positionData['tar.type']){ return }
if(positionData["tar.type"] == "Vessel"){
var targetCurrentTruePosition = this.truePositionForRelativePosition(
positionData["targetCurrentPosition"]["relativePosition"],
this.formatTruePositionVector(positionData.referenceBodies[positionData["tar.o.orbitingBody"]].currentTruePosition)
)
formattedData.vessels.push(this.buildVessel({
name: positionData["tar.name"],
type: "targetVessel",
truePosition: targetCurrentTruePosition,
referenceBodyName: positionData["tar.o.orbitingBody"]
}))
}
},
formatTargetCurrentCoordinates: function(positionData, formattedData){
if(this.rootReferenceBodyName != positionData["tar.o.orbitingBody"]){ return }
if(positionData["tar.type"] != "Vessel"){ return }
var currentPosition = positionData["targetCurrentPosition"]["relativePosition"]
var info = this.rootReferenceBody(positionData)
formattedData.targetCurrentCoordinates = this.coordinatesFromVector(currentPosition, info.radius)
},
formatTargetVessel: function(positionData, formattedData){
if(!positionData['tar.type']){ return }
if(positionData["tar.type"] == "Vessel"){
var targetCurrentTruePosition = this.truePositionForRelativePosition(
positionData["targetCurrentPosition"]["relativePosition"],
this.formatTruePositionVector(positionData.referenceBodies[positionData["tar.o.orbitingBody"]].currentTruePosition)
)
formattedData.vessels.push(this.buildVessel({
name: positionData["tar.name"],
type: "targetVessel",
truePosition: targetCurrentTruePosition,
referenceBodyName: positionData["tar.o.orbitingBody"]
}))
}
},
formatTargetVessel: function(positionData, formattedData){
if(!positionData['tar.type']){ return }
if(positionData["tar.type"] == "Vessel"){
var targetCurrentTruePosition = this.truePositionForRelativePosition(
positionData["targetCurrentPosition"]["relativePosition"],
this.formatTruePositionVector(positionData.referenceBodies[positionData["tar.o.orbitingBody"]].currentTruePosition)
)
formattedData.vessels.push(this.buildVessel({
name: positionData["tar.name"],
type: "targetVessel",
truePosition: targetCurrentTruePosition,
referenceBodyName: positionData["tar.o.orbitingBody"]
}))
}
},
getVesselAndTargetInfo: function(data){
if(this.isnoTarget(data)){return}
this.targetBody = this.datalink.getOrbitalBodyInfo(data['tar.name'])
this.targetBody.orbitingBody = this.datalink.getOrbitalBodyInfo(data['tar.o.orbitingBody'])
this.targetBody.periapsis = data['tar.o.ApA']
this.vessel.orbitingBody = this.datalink.getOrbitalBodyInfo(data['v.body'])
this.vessel.periapsis = data['o.ApA']
this.vessel.altitude = data['v.altitude']
this.vessel.orbitalVelocity = data['v.orbitalVelocity']
this.datalink.subscribeToData([
"b.o.gravParameter["+ this.vessel.orbitingBody.id +"]",
"b.radius["+ this.vessel.orbitingBody.id +"]",
"b.o.phaseAngle["+ this.targetBody.id +"]"
])
},
formatTargetVessel: function(positionData, formattedData){
if(!positionData['tar.type']){ return }
if(positionData["tar.type"] == "Vessel"){
var targetCurrentTruePosition = this.truePositionForRelativePosition(
positionData["targetCurrentPosition"]["relativePosition"],
this.formatTruePositionVector(positionData.referenceBodies[positionData["tar.o.orbitingBody"]].currentTruePosition)
)
formattedData.vessels.push(this.buildVessel({
name: positionData["tar.name"],
type: "targetVessel",
truePosition: targetCurrentTruePosition,
referenceBodyName: positionData["tar.o.orbitingBody"]
}))
}
},