• ArcGisRuntime100.14绘制曲线


          有时,在地图上显示为曲线的形状实际上是一系列连接的线性段,它们近似于曲线。对于许多用例(并且取决于您对数据所需的准确性),这是表示弯曲特征的可接受方式。ArcGIS 还可以使用准确表示曲线几何的线段来存储和显示几何。EllipticArcSegment在 ArcGIS Runtime 中,曲线段由或CubicBezierSegment类的实例表示。这些线段称为 真曲线

         您可以将曲线段添加到aMultipartBuilder中,如果几何体具有曲线,则曲线段会在适用的情况下从构成多部分几何体的集合中返回。曲线和线性段可以在同一个多部分几何图形中混合在一起。

        您可以使用GeometryEngine.Densify()基于多个线性段的真实曲线创建近似曲线。这样的曲线通常被称为致密曲线。默认情况下,不会从支持曲线的服务中获取曲线几何图形,这意味着将返回真实曲线几何图形的致密版本。用于ServiceCurveGeometryMode更改此默认行为。

        OnlyAllowTrueCurveUpdatesByTrueCurveClients默认情况下,无法更新存储在服务中的曲线几何图形为 true。要更新此类几何图形,请确保您的应用在整个工作流程中正确处理几何图形中的曲线段并设置ServiceCurveGeometryModeTrueCurveClient. 您必须在对服务进行任何调用之前执行此操作,因为在发出第一个请求后无法更改它。

    效果图

     源代码

    1. <esri:MapView Map="{Binding Map, Source={StaticResource MapViewModel}}" GraphicsOverlays="{Binding GraphicsOverlay,Source={StaticResource MapViewModel}}" >
    2. /esri:MapView>
    1. public class MapViewModel : INotifyPropertyChanged
    2. {
    3. public MapViewModel()
    4. {
    5. _map = new Map(SpatialReferences.WebMercator);
    6. GraphicsOverlay graphicsOverlay = MakeCurvedGraphicsOverlay();
    7. this.graphicsOverlay = new GraphicsOverlayCollection();
    8. this.graphicsOverlay.Add(graphicsOverlay);
    9. }
    10. private GraphicsOverlayCollection graphicsOverlay;
    11. public GraphicsOverlayCollection GraphicsOverlay
    12. {
    13. get { return graphicsOverlay; }
    14. set { graphicsOverlay = value; OnPropertyChanged(); }
    15. }
    16. private Map _map;
    17. ///
    18. /// Gets or sets the map
    19. ///
    20. public Map Map
    21. {
    22. get => _map;
    23. set { _map = value; OnPropertyChanged(); }
    24. }
    25. ///
    26. /// Raises the event
    27. ///
    28. /// The name of the property that has changed
    29. protected void OnPropertyChanged([CallerMemberName] string propertyName = null) =>
    30. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    31. public event PropertyChangedEventHandler PropertyChanged;
    32. private GraphicsOverlay MakeCurvedGraphicsOverlay()
    33. {
    34. // Create a simple fill symbol with outline.
    35. SimpleLineSymbol curvedLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 1);
    36. SimpleFillSymbol curvedFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Red, curvedLineSymbol);
    37. // Create a graphics overlay for the polygons with curve segments.
    38. GraphicsOverlay curvedGraphicsOverlay = new GraphicsOverlay();
    39. // Create and assign a simple renderer to the graphics overlay.
    40. curvedGraphicsOverlay.Renderer = new SimpleRenderer(curvedFillSymbol);
    41. // Create a heart-shaped graphic.
    42. MapPoint origin = new MapPoint(x: 40e5, y: 5e5, SpatialReferences.WebMercator);
    43. Geometry heartGeometry = MakeHeartGeometry(origin, 10e5);
    44. Graphic heartGraphic = new Graphic(heartGeometry);
    45. curvedGraphicsOverlay.Graphics.Add(heartGraphic);
    46. return curvedGraphicsOverlay;
    47. }
    48. private Geometry MakeHeartGeometry(MapPoint center, double sideLength)
    49. {
    50. if (sideLength <= 0) return null;
    51. SpatialReference spatialReference = center.SpatialReference;
    52. // The x and y coordinates to simplify the calculation.
    53. double minX = center.X - 0.5 * sideLength;
    54. double minY = center.Y - 0.5 * sideLength;
    55. // The radius of the arcs.
    56. double arcRadius = sideLength * 0.25;
    57. // Bottom left curve.
    58. MapPoint leftCurveStart = new MapPoint(center.X, minY, spatialReference);
    59. MapPoint leftCurveEnd = new MapPoint(minX, minY + 0.75 * sideLength, spatialReference);
    60. MapPoint leftControlMapPoint1 = new MapPoint(center.X, minY + 0.25 * sideLength, spatialReference);
    61. MapPoint leftControlMapPoint2 = new MapPoint(minX, center.Y, spatialReference: spatialReference);
    62. CubicBezierSegment leftCurve = new CubicBezierSegment(leftCurveStart, leftControlMapPoint1, leftControlMapPoint2, leftCurveEnd, spatialReference);
    63. // Top left arc.
    64. MapPoint leftArcCenter = new MapPoint(minX + 0.25 * sideLength, minY + 0.75 * sideLength, spatialReference);
    65. EllipticArcSegment leftArc = EllipticArcSegment.CreateCircularEllipticArc(leftArcCenter, arcRadius, Math.PI, centralAngle: -Math.PI, spatialReference);
    66. // Top right arc.
    67. MapPoint rightArcCenter = new MapPoint(minX + 0.75 * sideLength, minY + 0.75 * sideLength, spatialReference);
    68. EllipticArcSegment rightArc = EllipticArcSegment.CreateCircularEllipticArc(rightArcCenter, arcRadius, Math.PI, centralAngle: -Math.PI, spatialReference);
    69. // Bottom right curve.
    70. MapPoint rightCurveStart = new MapPoint(minX + sideLength, minY + 0.75 * sideLength, spatialReference);
    71. MapPoint rightCurveEnd = leftCurveStart;
    72. MapPoint rightControlMapPoint1 = new MapPoint(minX + sideLength, center.Y, spatialReference);
    73. MapPoint rightControlMapPoint2 = leftControlMapPoint1;
    74. CubicBezierSegment rightCurve = new CubicBezierSegment(rightCurveStart, rightControlMapPoint1, rightControlMapPoint2, rightCurveEnd, spatialReference);
    75. // Create the heart polygon.
    76. Part newPart = new Part(new Segment[]
    77. {
    78. leftCurve,
    79. leftArc,
    80. rightArc,
    81. rightCurve
    82. }, spatialReference);
    83. PolygonBuilder builder = new PolygonBuilder(spatialReference);
    84. builder.AddPart(newPart);
    85. return builder.ToGeometry();
    86. }
    87. }

  • 相关阅读:
    数据库插入时间类型数据,存储值与插入值相差1小时/13小时 java
    形参与实参
    降维(Dimensionality Reduction)
    1414;【17NOIP普及组】成绩(信奥一本通)
    多线程adsfasdfasdf
    如何快速生成项目目录结构树?
    【【verilog代码异步FIFO的设计解释+源码+tb】】
    node 第八天 使用前后端不分离的方式实现cookie登录验证
    一种近红外荧光探针吲哚菁绿伯胺ICG amine|1686147-55-6
    【PickerView案例14-复习第一天内容 Objective-C语言】
  • 原文地址:https://blog.csdn.net/qq_40098572/article/details/126662099