You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SceneView中使用EllipticArcSegment显示直线而非弧线的问题求助

SceneView中EllipticArcSegment显示为直线的解决方法

问题概述

使用EllipticArcSegment创建的弧线在MapView中可正常显示,但在SceneView中仅显示直线——核心原因是3D场景的渲染引擎不会像2D的MapView那样自动细分椭圆弧段来生成平滑弧线,需要手动处理几何结构。

解决步骤

在生成Polyline后,通过GeometryEngine.Densify方法手动对几何进行细分,设置合适的最大段长(单位与空间参考一致,此处WebMercator为米),让弧线在3D场景中呈现出平滑效果。

修改后的代码

public MainWindow()
{
    InitializeComponent();
    MySceneView.Scene = new Scene(BasemapStyle.ArcGISImageryStandard);
    MyMapView.Map = new Map(BasemapStyle.ArcGISTopographic);

    MapPoint _spain = new MapPoint(-4.00475, 40.637861, SpatialReferences.Wgs84);
    Graphic _arc = CreateArc(_spain, 0.080, 90.0, 45.0);
    Graphic _arc1 = CreateArc(_spain, 0.080, 90.0, 45.0);
    _AiminginZone_GO.Graphics.Add(_arc);
    _AiminginZone_GO1.Graphics.Add(_arc1);
    MyMapView.GraphicsOverlays.Add(_AiminginZone_GO);
    MySceneView.GraphicsOverlays.Add(_AiminginZone_GO1);
}

private Graphic CreateArc(MapPoint center, double radius, double arcAngle, double azimuth)
{
    _AiminginZone_GO.Graphics.Clear();
    _AiminginZone_GO1.Graphics.Clear();
    // set up spatial references
    SpatialReference wgs84 = SpatialReferences.Wgs84;
    SpatialReference webMercator = SpatialReferences.WebMercator;
    // make a point in lat/long (WGS84)
    MapPoint centrePoint = new MapPoint(center.X, center.Y, 56, wgs84);
    // project it to a mercator projection where the unit of measure is metres
    MapPoint mercatorPoint = (MapPoint)GeometryEngine.Project(centrePoint, webMercator);
    // create an arc segment which is 50Kilometers radius, starting at 90 degrees, the arc angle is 45 degrees clockwise
    EllipticArcSegment arcSegment = EllipticArcSegment.CreateCircularEllipticArc(mercatorPoint, 50000, (Math.PI / 180) * 90, (Math.PI / 180) * -45, webMercator);

    // make a part with the segment
    Part part = new Part(webMercator);
    part.Add(arcSegment);

    // create the line from the part
    Polyline line = new Polyline(part);

    // 关键:对几何进行细分,让3D场景能渲染出平滑弧线
    // 设置最大段长为1000米,可根据需求调整
    Polyline densifiedLine = (Polyline)GeometryEngine.Densify(line, 1000);

    // add it to a graphic and graphics overlay to allow us to visualise it
    var polylineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.Red, 3.0);
    // 使用细分后的几何创建Graphic
    Graphic arcGraphic = new Graphic(densifiedLine, polylineSymbol);
    return arcGraphic;
}

补充说明

  • Densify方法的第二个参数是最大段长,单位与当前几何的空间参考一致(此处WebMercator为米),数值越小弧线越平滑,但会增加几何复杂度,可根据实际需求调整(比如500米或2000米)。
  • 确保项目已引用ArcGIS.Core.Geometry命名空间,GeometryEngine属于该命名空间。

内容的提问来源于stack exchange,提问作者Francisco Lopez

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 15:24:08