2016-06-15 4 views
-3

ビジュアルスタジオ2015 C#を使用して、Webチュートリアルからポリラインソリューションを作成しました。ビジュアルスタジオでキュービック補間を実装する方法

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Data; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Imaging; 
using System.Windows.Navigation; 
using System.Windows.Shapes; 
using Microsoft.Maps.MapControl.WPF; 

using Microsoft.Maps.MapControl.WPF.Design; 


namespace WPFTestApplication 
{ 
    /// <summary> 
    /// Interaction logic for MainWindow.xaml 
    /// </summary> 
    public partial class MainWindow : Window 
    { 
     public MainWindow() 
     { 
      InitializeComponent(); 


       MapPolyline polyline = new MapPolyline(); 
       polyline.Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue); 
       polyline.StrokeThickness = 5; 
       polyline.Opacity = 0.7; 
       polygon.Locations = new LocationCollection() { 
    new Location(47.6424,-122.3219), 
    new Location(47.8424,-122.1747), 
    new Location(47.5814,-122.1747) 
    }; 


       myMap.Children.Add(polyline); 



     } 


    } 
} 

出力ディスプレイを次のように:

経度、緯度ポイントを次のように

<Window x:Class="WPFTestApplication.MainWindow" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF" 
Width="1024" Height="768"> 
<Grid x:Name="LayoutRoot" Background="White"> 
    <m:Map x:Name="myMap" CredentialsProvider="Insert_Your_Bing_Maps_Key" Center="47.740,-122.125" ZoomLevel="11"> 
     <m:MapPolyline Stroke="Blue" StrokeThickness="5" 
      Locations="47.6424,-122.3219 47.8424,-122.1747 47.5814,-122.1747 47.67856,-122.130994" 
      Opacity="0.7"/> 
    </m:Map> 
</Grid> 
</Window> 

xaml.csファイルは次のようhttps://msdn.microsoft.com/en-us/library/hh868034.aspx

XAMLファイルでありますマップ上のポリラインで接続されます。ポリラインは直線です。

キュービック/スプライン補間を使用して、経度、緯度点を接続して滑らかな曲線を作成することができます。このコードで立方体/スプライン補間を実装することは可能ですか?組み込み関数はありますか?

ありがとうございました。

答えて

-1

wpfから別のものを使用したい場合は、DrawCurvesを参照してください。これにより滑らかな曲線を描くことができます。

さらなる計算のためにスプライン上の点が必要な場合、またはMapPolylineに固執したい場合は、グーグルを一見するとthisなどのいくつかのプロジェクトが表示されるようです。最初にスプラインを自分で計算し、適切な数のポイントを取り、それらをポリラインオブジェクトに追加する必要があります(希望するスムーズさを得るため) 使用するクラス(MapPolyline)は、ポリゴンを描画するためにより少なくなります。 (あなたが経験しているように)直線で結ばれた点の数。

関連する問題