Moving geometry with epoch

I am trying to move a geometry along with my billboard and label. I’m creating czml files in python and I’m trying to add an ellipsoid to to follow a satellite I’m looking at.

So if I have two objects like so:


I would like to draw a 100m sphere around them to get a sense of scale.

If a line could be drawn and the length of that line is returned with each epoch that would also be of interest.

Hi @SolventDrip ,
Thanks for your post and welcome to the Cesium community.

For adding a sphere at the same location as your CZML models, you could use an entity. This sandcastle example Cesium Sandcastle shows how to create and position a Sphere Entity. For drawing a line between the two models you could use a Polyline Entity Cesium Sandcastle.

I hope that helps and please let us know if you have further questions.
Thanks,
Luke

Hi Luke,

Thanks for your response. I saw that example on the sphere but I don’t see where/how it shows anything about linking/attaching a sphere to an object inside a .czml file and updates its position w.r.t. the other object.

Like, right now (working in python) I’m working through some data and appending it to a list in the czml format before encoding it into a json file. The data works through a forloop of “sources” and what I’m doing right now is appending it to the list.

for source in sources:
   d_czml.append(
      {
         'id': {source},
          ... # building  data packet
      }
   )

   # The sphere that's supposed to follow the packet data below:
   d_czml.append(
    {
      "id": f"{source}_sphere",
      "name": f"Sphere Around {source}",
      "parent": f"{source}",
      "position": {
        "reference": f"{source}#position"
      },
      "ellipsoid": {
        "radii": {
          "cartesian": [100, 100, 100]
        },
        "material": {
          "solidColor": {
            "color": {
              # "rgba": [0, 0, 255, 50]  # Semi-transparent blue
              "rgba": colour[i][:2] + [50]
            }
          }
        },
        "outline": True,
        "outlineColor": {
          # "rgba": [0, 0, 255, 200]
          "rgba": colour[i][:2] + [200]
        }
      }
    }
  )

with open(data_dir / 'test_czml.czml', 'w') as f:
  f.write(json.dumps(d_czml))

The datapacket section works perfectly (as shown in my OP) but this section that’s meant to add the sphere runs a julianDate error so it’s not working correctly somewhere.

I did try and add it in with the “billboard” or around there and it didn’t show the sphere.

Where the (formatted for readability) source position data looks something like:

"position": {
   "interpolationAlgorithm": "LAGRANGE", 
   "interpolationDegree": 5, 
   "referenceFrame": "INERTIAL", 
   "cartesian": [
      "2022-12-28T00:03:00Z", -4393036.524, -1978967.914, -5183191.302, 
      "2022-12-28T00:06:00Z", -3570742.247, -1244795.108, -5981621.194999999, 
      "2022-12-28T00:09:00Z", -2600203.0840000003, -489291.636, -6562897.401000001, 
      "2022-12-28T00:12:00Z", -1516309.833, 256866.49599999998, -6906091.258, 
      "2022-12-28T00:15:00Z", -358739.081, 964354.078, -6998806.908, 
      "2022-12-28T00:18:00Z", 829466.275, 1606315.0080000001, -6837589.348, 
      "2022-12-28T00:21:00Z", 2003449.1479999998, 2159355.638, -6428057.665, 
      "2022-12-28T00:24:00Z", 3118191.8260000004, 2604388.785, -5784752.687, 
      "2022-12-28T00:27:00Z", 4130217.504, 2927299.5409999997, 
      ...,
   ],
}

Got it.
Problem was when I was calling the colours with:

colour[i][:2] + [50]

it was only calling the first two elements (RG) and then adds the “Alpha” layer of the list where what I needed to do was call:

colour[i][:3] + [50]

to call the first 3 elements (the RGB and then adds the Alpha layer)