本文介绍: 前期卫星地面站创建已经说过,本次说一下卫星和地面站可见性时卫星名称和轨迹线变色问题。因为随着可见性变色,需要在关系中获取到可见时间。3.创建卫星和地面站关系。

前期卫星地面站创建已经说过,本次说一下卫星和地面站可见性时卫星名称和轨迹线变色问题

1.创建卫星

// Get the current TLE for the given satellite identifier.
var tleList = TwoLineElementSetHelper.GetTles(m_satelliteIdentifier, JulianDate.Now);

// Use the epoch of the first TLE, since the TLE may have been loaded from offline data.
m_epoch = tleList[0].Epoch;

// Propagate the TLE and use that as the satellite's location point.
var locationPoint = new Sgp4Propagator(tleList).CreatePoint();
m_satellite = new Platform
{
	Name = "Satellite " + m_satelliteIdentifier,
	LocationPoint = locationPoint,
	// Orient the satellite using Vehicle Velocity Local Horizontal (VVLH) axes.
	OrientationAxes = new AxesVehicleVelocityLocalHorizontal(m_earth.FixedFrame, locationPoint),
};

// Set the identifier for the satellite in the CZML document.
m_satellite.Extensions.Add(new IdentifierExtension(m_satelliteIdentifier));

// Configure a glTF model for the satellite.
m_satellite.Extensions.Add(new ModelGraphicsExtension(new ModelGraphics
{
	// Link to a binary glTF file.
	Model = new CesiumResource(GetModelUri("satellite.glb"), CesiumResourceBehavior.LinkTo),
	// By default, Cesium plays all animations in the model simultaneously, which is not desirable.
	RunAnimations = false,
}));

2.创建地面站

// Define the location of the facility using cartographic coordinates.
var location = new Cartographic(Trig.DegreesToRadians(-75.596766667), Trig.DegreesToRadians(40.0388333333), 0.0);
var locationPoint = new PointCartographic(m_earth, location);
m_facility = new Platform
{
	Name = "AGI HQ",
	LocationPoint = locationPoint,
	// Orient the facility using East-North-Up (ENU) axes.
	OrientationAxes = new AxesEastNorthUp(m_earth, locationPoint),
};

// Set the identifier for the facility in the CZML document. 
m_facility.Extensions.Add(new IdentifierExtension("AGI"));

// Configure a glTF model for the facility.
m_facility.Extensions.Add(new ModelGraphicsExtension(new ModelGraphics
{
	// Link to a binary glTF file.
	Model = new CesiumResource(GetModelUri("facility.glb"), CesiumResourceBehavior.LinkTo),
	RunAnimations = false,
	HeightReference = CesiumHeightReference.ClampToGround,
}));

// Configure label for AGI HQ.
m_facility.Extensions.Add(new LabelGraphicsExtension(new LabelGraphics
{
	Text = m_facility.Name,
	FillColor = Color.White,
	// Only show label when camera is far enough from the satellite,
	// to avoid visually clashing with the model.
	DistanceDisplayCondition = new Bounds(1000.0, double.MaxValue),
	HeightReference = CesiumHeightReference.ClampToGround,
}));

3.创建卫星和地面站关系

m_satelliteFacilityLink = new LinkInstantaneous(m_facility, m_satellite);

// Set the identifier for the link in the CZML document. 
m_satelliteFacilityLink.Extensions.Add(new IdentifierExtension("SatelliteFacilityAccess"));

// Specify how access should be constrained.  In this case, 
// access will only exist when no part of the earth is between AGI HQ and the satellite.
m_accessQuery = new CentralBodyObstructionConstraint(m_satelliteFacilityLink, m_earth);

// Configure graphical display of the access link.
m_satelliteFacilityLink.Extensions.Add(new LinkGraphicsExtension(new LinkGraphics
{
	// Show the access link only when access is satisfied.
	Show = new AccessQueryCesiumProperty<bool>(m_accessQuery, true, false, false),
	Material = new SolidColorMaterialGraphics(Color.Yellow),
}));

因为随着可见性变色,需要在关系中获取到可见时间

AccessEvaluator evaluator = m_accessQuery.GetEvaluator();

// Compute the time intervals when the viewing location is able to see the satellite.
AccessQueryResult accessResult = evaluator.Evaluate(m_epoch, m_epoch.AddDays(1));
var accessIntervals = accessResult.SatisfactionIntervals;
var LabelResults = new TimeIntervalCollection<Color>();

LabelResults =GetColorList(accessIntervals, m_epoch, false);
m_satellite.Extensions.Add(new LabelGraphicsExtension(new LabelGraphics
{
	Text = new ConstantCesiumProperty<string>(m_satellite.Name),
	Font= new ConstantCesiumProperty<string>("20px"),
	FillColor = LabelResults,

}));

var LineResults = new TimeIntervalCollection<Color>();
LineResults = GetColorList(accessIntervals, m_epoch, true);
m_satellite.Extensions.Add(new PathGraphicsExtension(new PathGraphics
{
	Material = new PolylineOutlineMaterialGraphics
	{
		Color = LineResults,

		OutlineWidth = new ConstantCesiumProperty<double>(1.0),
		OutlineColor = new ConstantCesiumProperty<Color>(Color.Black),
	},
	Width = 2,
	LeadTime = Duration.FromMinutes(44).TotalSeconds,
	TrailTime = Duration.FromMinutes(44).TotalSeconds,
}));
  public static TimeIntervalCollection<Color> GetColorList(TimeIntervalCollection accessIntervals, Define.Link struLink,bool isLine)
  {
      var results = new TimeIntervalCollection<Color>();
      JulianDate tmp = new JulianDate();
      foreach (TimeInterval interval in accessIntervals)
      {
          if (results.Count() == 0)
          {
              results.Add(new TimeInterval<Color>(struLink.m_jBeginTime, interval.Start.ToGregorianDate().ToJulianDate(), Color.White, true, false));
          }

          if (tmp.ToString() != "")
          {
              results.Add(new TimeInterval<Color>(tmp, interval.Start.ToGregorianDate().ToJulianDate(), Color.White, true, false));
          }
          if(isLine)
          {
              results.Add(new TimeInterval<Color>(interval.Start.ToGregorianDate().ToJulianDate(), interval.Stop.ToGregorianDate().ToJulianDate(), Color.Red, false, true));
          }
          else
          {
              results.Add(new TimeInterval<Color>(interval.Start.ToGregorianDate().ToJulianDate(), interval.Stop.ToGregorianDate().ToJulianDate(), Color.Green, false, true));
          }

          tmp = interval.Stop.ToGregorianDate().ToJulianDate();
      }

      return results;
  }

效果

轨迹线和名称变色

原文地址:https://blog.csdn.net/windows_oracle/article/details/134663347

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如若转载,请注明出处:http://www.7code.cn/show_4573.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注