Inheritance: Geometry
 /// <summary>${utility_DictionaryConverter_method_ToGeoLine_D}</summary>
 public static GeoLine ToGeoLine(this PolylineElement polylineElement)
 {
     if (polylineElement != null && polylineElement.Point2Ds != null && polylineElement.Point2Ds.Count > 0)
     {
         GeoLine line = new GeoLine();
         line.Parts.Add(polylineElement.Point2Ds.Clone());
         return line;
     }
     return null;
 }
 internal GeoLine Clip(GeoLine line)
 {
     GeoLine newLine = new GeoLine();
     foreach (Point2DCollection points in line.Parts)
     {
         IList<Point2DCollection> list = this.ClipPointCollection(points, this.boundary);
         if ((list != null) && (list.Count > 0))
         {
             foreach (Point2DCollection points2 in list)
             {
                 newLine.Parts.Add(points2);
             }
             continue;
         }
     }
     return newLine;
 }
        private void MyMap_Loaded(object sender, RoutedEventArgs e)
        {
            #region 使用预定义点符号
            Feature featurePoint = new Feature();
            GeoPoint point = new GeoPoint();
            point.X = 116.2;
            point.Y = 39.6;
            PredefinedMarkerStyle simpleMarkerStyle = new PredefinedMarkerStyle();
            simpleMarkerStyle.Color = new SolidColorBrush(Colors.Red);
            simpleMarkerStyle.Size = 20;
            simpleMarkerStyle.Symbol = SuperMap.Web.Core.PredefinedMarkerStyle.MarkerSymbol.Star;
            featurePoint.Style = simpleMarkerStyle;
            featurePoint.Geometry = point;
            featuresLayer.Features.Add(featurePoint);
            #endregion

            #region 使用预定义线符号
            Feature featureLine = new Feature();
            Point2DCollection points = new Point2DCollection();
            points.Add(new Point2D(116.2, 39.6));
            points.Add(new Point2D(90, 50));
            points.Add(new Point2D(50, 25));
            points.Add(new Point2D(-80, 45));
            points.Add(new Point2D(-100, 38));
            ObservableCollection<Point2DCollection> path = new ObservableCollection<Point2DCollection>();
            path.Add(points);
            GeoLine geoLine = new GeoLine();
            geoLine.Parts = path;

            PredefinedLineStyle simpleLineStyle = new PredefinedLineStyle();
            simpleLineStyle.Stroke = new SolidColorBrush(Colors.Black);
            simpleLineStyle.StrokeThickness = 1;
            simpleLineStyle.StrokeDashArray = new DoubleCollection { 3, 1 };

            featureLine.Geometry = geoLine;
            featureLine.Style = simpleLineStyle;
            featuresLayer.Features.Add(featureLine);
            #endregion

            #region 使用预定义面符号
            Feature featureRegion = new Feature();
            Point2DCollection pointsRegion = new Point2DCollection();
            pointsRegion.Add(new Point2D(-8, 61));
            pointsRegion.Add(new Point2D(-6, 55));
            pointsRegion.Add(new Point2D(-8, 50));
            pointsRegion.Add(new Point2D(2, 50));
            pointsRegion.Add(new Point2D(1, 61));
            pointsRegion.Add(new Point2D(-8, 61));
            ObservableCollection<Point2DCollection> pRegion = new ObservableCollection<Point2DCollection>();
            pRegion.Add(pointsRegion);
            GeoRegion geoRegion = new GeoRegion();
            geoRegion.Parts = pRegion;

            PredefinedFillStyle simpleFillStyle = new PredefinedFillStyle();
            simpleFillStyle.StrokeThickness = 1;
            simpleFillStyle.Stroke = new SolidColorBrush(Colors.Black);
            simpleFillStyle.Fill = new SolidColorBrush(Colors.Yellow);

            featureRegion.Geometry = geoRegion;
            featureRegion.Style = simpleFillStyle;
            featuresLayer.Features.Add(featureRegion);
            #endregion

            #region 添加文本
            Feature featureText = new Feature();
            GeoPoint text = new GeoPoint();
            text.X = 5;
            text.Y = 10;

            TextStyle textStyle = new TextStyle();
            textStyle.Text = "Africa";
            textStyle.FontSize = 40;
            textStyle.Foreground = new SolidColorBrush(Colors.Blue);

            featureText.Geometry = text;
            featureText.Style = textStyle;
            featuresLayer.Features.Add(featureText);
            #endregion
        }
        private void endDraw(bool isDblClick = false, bool isCancel = false)
        {
            if (points != null)
            {
                if (isDblClick)
                {
                    points.RemoveAt(points.Count - 1);
                }
                PolylineElement pLine = new PolylineElement()
                {
                    Point2Ds = this.points.Clone(),
                    #region 所有风格的控制
                    Stroke = this.Stroke,
                    StrokeThickness = this.StrokeThickness,
                    StrokeMiterLimit = this.StrokeMiterLimit,
                    StrokeDashOffset = this.StrokeDashOffset,
                    StrokeDashArray = this.StrokeDashArray,
                    StrokeDashCap = this.StrokeDashCap,
                    StrokeEndLineCap = this.StrokeEndLineCap,
                    StrokeLineJoin = this.StrokeLineJoin,
                    StrokeStartLineCap = this.StrokeStartLineCap,
                    Opacity = this.Opacity,
                    Fill = this.Fill,
                    FillRule = this.FillRule
                    #endregion
                };
                GeoLine geoLine = new GeoLine();//构造返回的Geometry
                geoLine.Parts.Add(points);
                DrawEventArgs args = new DrawEventArgs
                {
                    DrawName = Name,
                    Element = pLine,    //Element = this.polyline  //直接返回是固定像素的
                    Geometry = geoLine,
                    Canceled = isCancel
                };

                Deactivate();
                OnDrawCompleted(args);
            }
        }
 //预留接口
 private static GeoLine ToGeoLine(XElement xe)
 {
     GeoLine line = new GeoLine();
     return line;
 }
        internal GeoLine ToGeoLine()
        {
            if (this.Parts != null)
            {
                List<Point2DCollection> pss = new List<Point2DCollection>();
                Point2DCollection copy = new Point2DCollection();

                foreach (Point2D item in this.Point2Ds)
                {
                    copy.Add(item);
                }
                for (int i = 0; i < this.Parts.Count; i++)
                {
                    Point2DCollection temp = new Point2DCollection();
                    for (int j = 0; j < this.Parts[i]; j++)
                    {
                        temp.Add(copy[j]);
                    }
                    pss.Add(temp);

                    copy.RemoveRange(0, this.Parts[i]);//把前面的删除
                } //把Point2Ds根据Parts分成一段一段的

                GeoLine line = new GeoLine();
                foreach (Point2DCollection item in pss)
                {
                    line.Parts.Add(item);
                }
                return line;
            }
            return null;
        }
Esempio n. 7
0
        //添加虚拟线;
        private void addHoverLineSegment(Point2D p0 , Point2D p1 , int index0 , int index1 , Feature feature , Point2DCollection points , int partIndex)
        {
            GeoLine line = new GeoLine();
            line.Parts.Add(new Point2DCollection() { p0 , p1 });
            Feature segment = new Feature() { Geometry = line , Style = hoverLineStyle };
            segment.SetZIndex(1);

            segment.Attributes.Add("Point2DCollection" , points);
            segment.Attributes.Add("Feature" , feature);
            segment.Attributes.Add("Index0" , index0);
            segment.Attributes.Add("Index1" , index1);
            segment.Attributes.Add("PartIndex" , partIndex);

            hoverLayer.Features.Add(segment);
        }
 /// <summary>${core_GeoLine_method_clone_D}</summary>
 public override Geometry Clone()
 {
     GeoLine line = new GeoLine();
     if (this.Parts != null)
     {
         foreach (Point2DCollection points in this.Parts)
         {
             if (points != null)
             {
                 Point2DCollection item = new Point2DCollection();
                 foreach (Point2D point in points)
                 {
                     if (point != null)
                     {
                         item.Add(point.Clone());
                     }
                 }
                 line.Parts.Add(item);
                 continue;
             }
             line.Parts.Add(null);
         }
     }
     return line;
 }
 private GeoLine ParseMultiLineCoordinates(XElement eles)
 {
     GeoLine line = new GeoLine();
     if (eles != null)
     {
         if (!string.IsNullOrEmpty(eles.Value))
         {
             string[] values = eles.Value.Trim().Split(',', ' ');
             line.Parts.Add(this.GetPoint2Ds(values));
         }
     }
     return line;
 }
        private void service_ProcessCompleted(object sender, RouteEventArgs e)
        {
            //预定义线样式
            PredefinedLineStyle style = new PredefinedLineStyle { Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 3 };
            //对结果进行判断,增强程序健壮性

            if (e.Result == null)
            {
                MessageBox.Show("查询无结果");
                return;
            }

            if (e.Result.NodePositions == null)
            {
                MessageBox.Show("查询无结果");
                return;
            }

            if (e.Result.NodePositions.Count == 0)
            {
                MessageBox.Show("查询无结果");
                return;
            }

            GeoLine line = new GeoLine();
            line.Parts.Add(e.Result.NodePositions);
            //将feature 添加到图层中
            Feature feature = new Feature { Geometry = line, Style = style };
            featuresLayer.AddFeature(feature);
        }