예제 #1
0
 private void RenderFeature(SKCanvas canvas, IViewport viewport, IStyle style, IFeature feature)
 {
     if (feature.Geometry is Point)
     {
         PointRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, _symbolTextureCache);
     }
     else if (feature.Geometry is MultiPoint)
     {
         MultiPointRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, _symbolTextureCache);
     }
     else if (feature.Geometry is LineString)
     {
         LineStringRenderer.Draw(canvas, viewport, style, feature.Geometry);
     }
     else if (feature.Geometry is MultiLineString)
     {
         MultiLineStringRenderer.Draw(canvas, viewport, style, feature.Geometry);
     }
     else if (feature.Geometry is Polygon)
     {
         PolygonRenderer.Draw(canvas, viewport, style, feature.Geometry);
     }
     else if (feature.Geometry is MultiPolygon)
     {
         MultiPolygonRenderer.Draw(canvas, viewport, style, feature.Geometry);
     }
     else if (feature.Geometry is IRaster)
     {
         RasterRenderer.Draw(canvas, viewport, style, feature, _tileTextureCache, _currentIteration);
     }
 }
예제 #2
0
 private void RenderFeature(SKCanvas canvas, IReadOnlyViewport viewport, IStyle style, IFeature feature, float layerOpacity)
 {
     if (feature.Geometry is Point)
     {
         PointRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, _symbolCache, layerOpacity * style.Opacity);
     }
     else if (feature.Geometry is MultiPoint)
     {
         MultiPointRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, _symbolCache, layerOpacity * style.Opacity);
     }
     else if (feature.Geometry is LineString)
     {
         LineStringRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity);
     }
     else if (feature.Geometry is MultiLineString)
     {
         MultiLineStringRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity);
     }
     else if (feature.Geometry is Polygon)
     {
         PolygonRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity, _symbolCache);
     }
     else if (feature.Geometry is MultiPolygon)
     {
         MultiPolygonRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity, _symbolCache);
     }
     else if (feature.Geometry is IRaster)
     {
         RasterRenderer.Draw(canvas, viewport, style, feature, layerOpacity * style.Opacity, _tileCache, _currentIteration);
     }
 }
        public static void Draw(SKCanvas canvas, IViewport viewport, IStyle style, IFeature feature, IGeometry geometry)
        {
            var multiLineString = (MultiLineString)geometry;

            foreach (var lineString in multiLineString)
            {
                LineStringRenderer.Draw(canvas, viewport, style, feature, lineString);
            }
        }
예제 #4
0
 public static void Draw(SKCanvas canvas, IReadOnlyViewport viewport, IStyle style, IFeature feature,
                         MultiLineString multiLineString, float opacity)
 {
     foreach (var geometry in multiLineString.Geometries)
     {
         var lineString = (LineString)geometry;
         LineStringRenderer.Draw(canvas, viewport, style, feature, lineString, opacity);
     }
 }
예제 #5
0
파일: MapRenderer.cs 프로젝트: tle5/Mapsui
 private void RenderFeature(SKCanvas canvas, IReadOnlyViewport viewport, ILayer layer, IStyle style, IFeature feature, float layerOpacity)
 {
     // Check, if we have a special renderer for this style
     if (StyleRenderers.ContainsKey(style.GetType()))
     {
         // Save canvas
         canvas.Save();
         // We have a special renderer, so try, if it could draw this
         var result = ((ISkiaStyleRenderer)StyleRenderers[style.GetType()]).Draw(canvas, viewport, layer, feature, style, _symbolCache);
         // Restore old canvas
         canvas.Restore();
         // Was it drawn?
         if (result)
         {
             // Yes, special style renderer drawn correct
             return;
         }
     }
     // No special style renderer handled this up to now, than try standard renderers
     if (feature.Geometry is Point)
     {
         PointRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, _symbolCache, layerOpacity * style.Opacity);
     }
     else if (feature.Geometry is MultiPoint)
     {
         MultiPointRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, _symbolCache, layerOpacity * style.Opacity);
     }
     else if (feature.Geometry is LineString)
     {
         LineStringRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity);
     }
     else if (feature.Geometry is MultiLineString)
     {
         MultiLineStringRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity);
     }
     else if (feature.Geometry is Polygon)
     {
         PolygonRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity, _symbolCache);
     }
     else if (feature.Geometry is MultiPolygon)
     {
         MultiPolygonRenderer.Draw(canvas, viewport, style, feature, feature.Geometry, layerOpacity * style.Opacity, _symbolCache);
     }
     else if (feature.Geometry is IRaster)
     {
         RasterRenderer.Draw(canvas, viewport, style, feature, layerOpacity * style.Opacity, _tileCache, _currentIteration);
     }
 }
예제 #6
0
 private static void Draw(SKCanvas canvas, IReadOnlyViewport viewport, IStyle style, float layerOpacity,
                          IFeature feature, Geometry?geometry, SymbolCache symbolCache)
 {
     if (geometry is Point point)
     {
         PointRenderer.Draw(canvas, viewport, style, feature, point.X, point.Y, symbolCache,
                            layerOpacity * style.Opacity);
     }
     else if (geometry is MultiPoint multiPoint)
     {
         MultiPointRenderer.Draw(canvas, viewport, style, feature, multiPoint,
                                 symbolCache, layerOpacity * style.Opacity);
     }
     else if (geometry is LineString lineString)
     {
         LineStringRenderer.Draw(canvas, viewport, style, feature, lineString,
                                 layerOpacity * style.Opacity);
     }
     else if (geometry is MultiLineString multiLineString)
     {
         MultiLineStringRenderer.Draw(canvas, viewport, style, feature, multiLineString,
                                      layerOpacity * style.Opacity);
     }
     else if (geometry is Polygon polygon)
     {
         PolygonRenderer.Draw(canvas, viewport, style, feature, polygon,
                              layerOpacity * style.Opacity, symbolCache);
     }
     else if (geometry is MultiPolygon multiPolygon)
     {
         MultiPolygonRenderer.Draw(canvas, viewport, style, feature, multiPolygon,
                                   layerOpacity * style.Opacity, symbolCache);
     }
     else if (geometry is GeometryCollection collection)
     {
         for (var i = 0; i < collection.NumGeometries; i++)
         {
             Draw(canvas, viewport, style, layerOpacity, feature, collection.GetGeometryN(i), symbolCache);
         }
     }
     else
     {
         Logger.Log(LogLevel.Warning,
                    $"Failed to find renderer for geometry feature of type {geometry?.GetType()}");
     }
 }
예제 #7
0
        public bool Draw(SKCanvas canvas, IReadOnlyViewport viewport, ILayer layer, IFeature feature, IStyle style, ISymbolCache symbolCache, long iteration)
        {
            try
            {
                var vectorStyle = (VectorStyle)style;
                var opacity = (float)(layer.Opacity * style.Opacity);

                switch (feature)
                {
                    case RectFeature rectFeature:
                        PolygonRenderer.Draw(canvas, viewport, vectorStyle, rectFeature, rectFeature.Rect.ToPolygon(), opacity);
                        break;
                    case PointFeature pointFeature:
                        SymbolStyleRenderer.DrawSymbol(canvas, viewport, layer, pointFeature.Point.X, pointFeature.Point.Y, new SymbolStyle { Outline = vectorStyle.Outline, Fill = vectorStyle.Fill, Line = vectorStyle.Line });
                        break;
                    case GeometryFeature geometryFeature:
                        switch (geometryFeature.Geometry)
                        {
                            case GeometryCollection collection:
                                for (var i = 0; i < collection.NumGeometries; i++)
                                    Draw(canvas, viewport, layer, new GeometryFeature(collection.GetGeometryN(i)), style, symbolCache, iteration);
                                break;
                            case Point point:
                                Draw(canvas, viewport, layer, new PointFeature(point.X, point.Y), style, symbolCache, iteration);
                                break;
                            case Polygon polygon:
                                PolygonRenderer.Draw(canvas, viewport, vectorStyle, feature, polygon, opacity, symbolCache);
                                break;
                            case LineString lineString:
                                LineStringRenderer.Draw(canvas, viewport, vectorStyle, lineString, opacity);
                                break;
                            default:
                                throw new ArgumentException("Unknown geometry of Feature");
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex.Message, ex);
            }

            return true;
        }