Example #1
0
 private void ConvertPointsToPolyline(BaseContent p, PoiGraphic g)
 {
     var pc = ConvertPointsToPointCollection(p);
     if (pc == null) return;
     var pol = new Polyline();
     pol.Paths.Add(pc);
     g.SetGeometry(pol);
 }
Example #2
0
 /// <summary>
 /// Convert a polyline to a graphic.
 /// NOTE Although we could have used a Polyline to create the graphic, it would mean that we cannot specify the fill color,
 /// which is why I've chosen to convert it to a Polygon.
 /// </summary>
 /// <param name="ls"></param>
 /// <param name="g"></param>
 private void ConvertPolylineToGraphic(LineString ls, PoiGraphic g)
 {
     var polygon = new Polygon();
     var pc = new PointCollection();
     foreach (var point in ls.Line)
     {
         pc.Add(mercator.FromGeographic(new MapPoint(point.X, point.Y)) as MapPoint);
     }
     //if (pc.First().X != pc.Last().X || pc.First().Y != pc.Last().Y)
     //    pc.Add(pc.First());
     polygon.Rings.Add(pc);
     g.SetGeometry(polygon);
 }
Example #3
0
 private void ConvertGeometryToPolygon(PoI p, PoiGraphic g)
 {
     var polygon = new Polygon();
     if (p.Geometry is csCommon.Types.Geometries.Polygon)
     {
         var geom = p.Geometry as csCommon.Types.Geometries.Polygon;
         foreach (var ls in geom.LineStrings)
         {
             var pc = new PointCollection();
             foreach (var ps in ls.Line)
             {
                 pc.Add(mercator.FromGeographic(new MapPoint(ps.X, ps.Y)) as MapPoint);
             }
             if (pc.First().X != pc.Last().X || pc.First().Y != pc.Last().Y)
                 pc.Add(pc.First());
             polygon.Rings.Add(pc);
         }
         g.SetGeometry(polygon);
     }
     else return;
 }
Example #4
0
 private void ConvertPolygonToGraphic(csCommon.Types.Geometries.Polygon p, PoiGraphic g)
 {
     var polygon = new Polygon();
     foreach (var ls in p.LineStrings)
     {
         var pc = new PointCollection();
         foreach (var point in ls.Line)
         {
             pc.Add(mercator.FromGeographic(new MapPoint(point.X, point.Y)) as MapPoint);
         }
         if (pc.First().X != pc.Last().X || pc.First().Y != pc.Last().Y)
             pc.Add(pc.First());
         polygon.Rings.Add(pc);
     }
     g.SetGeometry(polygon);
 }
Example #5
0
 private void ConvertPointsToPolygon(BaseContent p, PoiGraphic g)
 {
     var pc = ConvertPointsToPointCollection(p);
     if (pc == null) return;
     var polygon = new Polygon();
     pc.Add(pc[0]); // Close the loop
     polygon.Rings.Add(pc);
     g.SetGeometry(polygon);
 }