Esempio n. 1
0
        protected void RenderGeometry(Graphics g, Map map, Geometry feature, VectorStyle style)
        {
            GeometryType2 geometryType = feature.GeometryType;

            switch (geometryType)
            {
            case GeometryType2.Polygon:
                if (style.EnableOutline)
                {
                    VectorRenderer.DrawPolygon(g, (Polygon)feature, style.Fill, style.Outline, _clippingEnabled,
                                               map);
                }
                else
                {
                    VectorRenderer.DrawPolygon(g, (Polygon)feature, style.Fill, null, _clippingEnabled, map);
                }
                break;

            case GeometryType2.MultiPolygon:
                if (style.EnableOutline)
                {
                    VectorRenderer.DrawMultiPolygon(g, (MultiPolygon)feature, style.Fill, style.Outline,
                                                    _clippingEnabled, map);
                }
                else
                {
                    VectorRenderer.DrawMultiPolygon(g, (MultiPolygon)feature, style.Fill, null, _clippingEnabled,
                                                    map);
                }
                break;

            case GeometryType2.LineString:
                if (style.LineSymbolizer != null)
                {
                    style.LineSymbolizer.Render(map, (LineString)feature, g);
                    return;
                }
                VectorRenderer.DrawLineString(g, (LineString)feature, style.Line, map, style.LineOffset);
                return;

            case GeometryType2.MultiLineString:
                if (style.LineSymbolizer != null)
                {
                    style.LineSymbolizer.Render(map, (MultiLineString)feature, g);
                    return;
                }
                VectorRenderer.DrawMultiLineString(g, (MultiLineString)feature, style.Line, map, style.LineOffset);
                break;

            case GeometryType2.Point:
                if (style.PointSymbolizer != null)
                {
                    VectorRenderer.DrawPoint(style.PointSymbolizer, g, (Point)feature, map);
                    return;
                }

                if (style.Symbol != null || style.PointColor == null)
                {
                    VectorRenderer.DrawPoint(g, (Point)feature, style.Symbol, style.SymbolScale, style.SymbolOffset,
                                             style.SymbolRotation, map);
                    return;
                }
                VectorRenderer.DrawPoint(g, (Point)feature, style.PointColor, style.PointSize, style.SymbolOffset, map);

                break;

            case GeometryType2.MultiPoint:
                //case "SharpMap.Geometries.MultiPoint":
                if (style.PointSymbolizer != null)
                {
                    VectorRenderer.DrawMultiPoint(style.PointSymbolizer, g, (MultiPoint)feature, map);
                }
                if (style.Symbol != null || style.PointColor == null)
                {
                    VectorRenderer.DrawMultiPoint(g, (MultiPoint)feature, style.Symbol, style.SymbolScale,
                                                  style.SymbolOffset, style.SymbolRotation, map);
                }
                else
                {
                    VectorRenderer.DrawMultiPoint(g, (MultiPoint)feature, style.PointColor, style.PointSize, style.SymbolOffset, map);
                }
                break;

            case GeometryType2.GeometryCollection:
                //case "SharpMap.Geometries.GeometryCollection":
                foreach (Geometry geom in (GeometryCollection)feature)
                {
                    RenderGeometry(g, map, geom, style);
                }
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Method to render <paramref name="feature"/> using <paramref name="style"/>
        /// </summary>
        /// <param name="g">The graphics object</param>
        /// <param name="map">The map</param>
        /// <param name="feature">The feature's geometry</param>
        /// <param name="style">The style to apply</param>
        protected void RenderGeometry(Graphics g, Map map, IGeometry feature, VectorStyle style)
        {
            if (feature == null)
            {
                return;
            }

            var geometryType = feature.OgcGeometryType;

            switch (geometryType)
            {
            case OgcGeometryType.Polygon:
                if (style.EnableOutline)
                {
                    VectorRenderer.DrawPolygon(g, (IPolygon)feature, style.Fill, style.Outline, _clippingEnabled,
                                               map);
                }
                else
                {
                    VectorRenderer.DrawPolygon(g, (IPolygon)feature, style.Fill, null, _clippingEnabled, map);
                }
                break;

            case OgcGeometryType.MultiPolygon:
                if (style.EnableOutline)
                {
                    VectorRenderer.DrawMultiPolygon(g, (IMultiPolygon)feature, style.Fill, style.Outline,
                                                    _clippingEnabled, map);
                }
                else
                {
                    VectorRenderer.DrawMultiPolygon(g, (IMultiPolygon)feature, style.Fill, null, _clippingEnabled,
                                                    map);
                }
                break;

            case OgcGeometryType.LineString:
                if (style.LineSymbolizer != null)
                {
                    style.LineSymbolizer.Render(map, (ILineString)feature, g);
                    return;
                }
                VectorRenderer.DrawLineString(g, (ILineString)feature, style.Line, map, style.LineOffset);
                return;

            case OgcGeometryType.MultiLineString:
                if (style.LineSymbolizer != null)
                {
                    style.LineSymbolizer.Render(map, (IMultiLineString)feature, g);
                    return;
                }
                VectorRenderer.DrawMultiLineString(g, (IMultiLineString)feature, style.Line, map, style.LineOffset);
                break;

            case OgcGeometryType.Point:
                if (style.PointSymbolizer != null)
                {
                    VectorRenderer.DrawPoint(style.PointSymbolizer, g, (IPoint)feature, map);
                    return;
                }

                if (style.Symbol != null || style.PointColor == null)
                {
                    VectorRenderer.DrawPoint(g, (IPoint)feature, style.Symbol, style.SymbolScale, style.SymbolOffset,
                                             style.SymbolRotation, map);
                    return;
                }
                VectorRenderer.DrawPoint(g, (IPoint)feature, style.PointColor, style.PointSize, style.SymbolOffset, map);

                break;

            case OgcGeometryType.MultiPoint:
                if (style.PointSymbolizer != null)
                {
                    VectorRenderer.DrawMultiPoint(style.PointSymbolizer, g, (IMultiPoint)feature, map);
                }
                if (style.Symbol != null || style.PointColor == null)
                {
                    VectorRenderer.DrawMultiPoint(g, (IMultiPoint)feature, style.Symbol, style.SymbolScale,
                                                  style.SymbolOffset, style.SymbolRotation, map);
                }
                else
                {
                    VectorRenderer.DrawMultiPoint(g, (IMultiPoint)feature, style.PointColor, style.PointSize, style.SymbolOffset, map);
                }
                break;

            case OgcGeometryType.GeometryCollection:
                IGeometryCollection coll = (IGeometryCollection)feature;
                for (var i = 0; i < coll.NumGeometries; i++)
                {
                    IGeometry geom = coll[i];
                    RenderGeometry(g, map, geom, style);
                }
                break;

            default:
                break;
            }
        }