How to use the tar.type function in tar

To help you get started, we’ve selected a few tar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tcannonfodder / houston / public / assets / js / position_data_formatter.js View on Github external
formatReferenceBodies: function(positionData, formattedData){
    referenceBodyNames = Object.keys(positionData.referenceBodies)

    for (var i = referenceBodyNames.length - 1; i >= 0; i--) {
      var name = referenceBodyNames[i]
      var info = positionData.referenceBodies[name]
      var type = "currentPosition"

      if(positionData["tar.type"] == "CelestialBody" && positionData["tar.name"] == name){
        type = "targetBodyCurrentPosition"
      }

      var x = this.buildReferenceBody({
        name: name,
        type: type,
        radius: info.radius,
        truePosition: this.formatTruePositionVector(info.currentTruePosition),
        atmosphericRadius: this.datalink.getOrbitalBodyInfo(name).atmosphericRadius,
        color: this.datalink.getOrbitalBodyInfo(name).color
      })

      formattedData["referenceBodies"].push(x)
    }
  },
github tcannonfodder / houston / static / js / position_data_formatter.js View on Github external
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"]
      }))
    }
  },
github tcannonfodder / houston / static / js / position_data_formatter.js View on Github external
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"]
      }))
    }
  },
github tcannonfodder / houston / static / js / position_data_formatter.js View on Github external
formatReferenceBodies: function(positionData, formattedData){
    referenceBodyNames = Object.keys(positionData.referenceBodies)

    for (var i = referenceBodyNames.length - 1; i >= 0; i--) {
      var name = referenceBodyNames[i]
      var info = positionData.referenceBodies[name]
      var type = "currentPosition"

      if(positionData["tar.type"] == "CelestialBody" && positionData["tar.name"] == name){
        type = "targetBodyCurrentPosition"
      }

      var x = this.buildReferenceBody({
        name: name,
        type: type,
        radius: info.radius,
        truePosition: this.formatTruePositionVector(info.currentTruePosition),
        atmosphericRadius: this.datalink.getOrbitalBodyInfo(name).atmosphericRadius,
        color: this.datalink.getOrbitalBodyInfo(name).color
      })

      formattedData["referenceBodies"].push(x)
    }
  },
github tcannonfodder / houston / static / js / docking_position_data.js View on Github external
this.datalink.sendMessage(requestParams, function(data){
      positionData["vesselCurrentPosition"]["truePosition"] = this.truePositionForRelativePosition(
        data["vesselRelativePosition"], data["vesselBodyTruePosition"]
      )

      if(positionData['tar.type']){
        if(positionData['tar.o.orbitPatches']){
          positionData["targetCurrentPosition"]["truePosition"] = this.truePositionForRelativePosition(
            data["targetRelativePosition"], data["targetBodyTruePosition"]
          )
        } else{
          positionData["targetCurrentPosition"]["truePosition"] = data["targetTruePosition"]
        }
      }

      this.mutexUnlock()
      this.options.onRecalculate && this.options.onRecalculate(positionData)
    }.bind(this))
  },
github tcannonfodder / houston / public / assets / js / position_data_formatter.js View on Github external
formatTargetOrbitPatches: function(positionData, formattedData){
    if(!positionData['tar.type']){ return }
    if(positionData["tar.o.orbitPatches"].length > 0){
      formattedData.orbitPatches = formattedData.orbitPatches.concat(this.formatOrbitPatches(
        formattedData, positionData, positionData["tar.o.orbitPatches"], {
          type: "orbitPatch",
          parentType: "targetVessel",
          parentName: positionData["tar.name"]
        },{ linkedPatchType: "orbitPatch" }
      ))
    }
  },
github tcannonfodder / houston / static / js / orbital_position_data.js View on Github external
getPositionsAndRecalculate: function(positionData){
    var requestParams = {};
    //ask for the true position for the current body right now and the radius
    var referenceBody = this.datalink.getOrbitalBodyInfo(positionData["vesselBody"])
    this.rootReferenceBody = referenceBody
    requestParams["currentReferenceBodyRadius"] = 'b.radius[' + referenceBody.id + ']'
    requestParams["currentReferenceBodyTruePosition"] = 'b.o.truePositionAtUT[' + referenceBody.id + ',' + positionData["currentUniversalTime"] + ']'
    //ask for the relative position of the vessel in the current orbit patch at the current time
    requestParams["vesselCurrentPositionRelativePosition"] = "o.relativePositionAtUTForOrbitPatch[" + 0 +","+ positionData["currentUniversalTime"] + "]"

    this.buildRelativePositionRequestsForOrbitPatches(requestParams, "vesselCurrentOrbit", positionData['o.orbitPatches'], positionData["currentUniversalTime"])
    this.buildRelativePositionRequestsForManeuverNodeOrbitPatches(requestParams, "vesselManeuverNodes", positionData['o.maneuverNodes'], positionData["currentUniversalTime"])

    if(positionData['tar.type']){
      if(positionData['tar.o.orbitPatches'] && positionData['tar.o.orbitPatches'].length > 0){
        this.buildRelativePositionRequestsForOrbitPatches(requestParams, "targetCurrentOrbit", positionData['tar.o.orbitPatches'], positionData["currentUniversalTime"], 'tar.o')
        requestParams["targetCurrentPositionRelativePosition"] = "tar.o.relativePositionAtUTForOrbitPatch[" + 0 +","+ positionData["currentUniversalTime"] + "]"
      } else{
        var body = this.datalink.getOrbitalBodyInfo(positionData['tar.name'])
        requestParams[body.name + "[metadata]radius"] = 'b.radius[' + body.id + ']'
        requestParams[body.name + "["+ positionData["currentUniversalTime"] +"]TruePosition"] = 'b.o.truePositionAtUT[' + body.id + ',' + positionData["currentUniversalTime"] + ']'
        requestParams[body.name + "[metadata]currentTruePosition"] = 'b.o.truePositionAtUT[' + body.id + ',' + positionData["currentUniversalTime"] + ']'
      }
    }

    this.datalink.sendMessage(requestParams, function(data){
      positionData["currentReferenceBodyRadius"] = data["currentReferenceBodyRadius"]
      positionData["currentReferenceBodyTruePosition"] = data["currentReferenceBodyTruePosition"]

      this.buildReferenceBodyPositionData(data, positionData)
github tcannonfodder / houston / public / assets / js / position_data_formatter.js View on Github external
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"]
      }))
    }
  },
github tcannonfodder / houston / static / js / ground_track_position_data_formatter.js View on Github external
formatTargetOrbitalPaths: function(positionData, formattedData){
    if(positionData["tar.type"] != "Vessel"){ return }
    var parentType = "targetVessel"
    var orbitPatches = positionData["tar.o.orbitPatches"]

    var pathSet = this.formatPathSet(positionData, orbitPatches, parentType, "orbitPath")

    formattedData.targetOrbitalPaths = pathSet.filter(function(x){ return x.type == "orbital" })
    formattedData.targetSuborbitalPaths = pathSet.filter(function(x){ return x.type == "suborbital" })
  },
github tcannonfodder / houston / static / js / position_data_formatter.js View on Github external
formatTargetOrbitPatches: function(positionData, formattedData){
    if(!positionData['tar.type']){ return }
    if(positionData["tar.o.orbitPatches"].length > 0){
      formattedData.orbitPatches = formattedData.orbitPatches.concat(this.formatOrbitPatches(
        formattedData, positionData, positionData["tar.o.orbitPatches"], {
          type: "orbitPatch",
          parentType: "targetVessel",
          parentName: positionData["tar.name"]
        },{ linkedPatchType: "orbitPatch" }
      ))
    }
  },