Exemple #1
0
        /// <summary>
        /// Renders a geometry to the screen depending on the geometry type.
        /// </summary>
        /// <param name="g">The graphics object used to draw geometries.</param>
        /// <param name="map">The map the geometry belongs to and is rendered onto.</param>
        /// <param name="feature">The feature of which his geometry will be rendered.</param>
        /// <param name="style">The style to use when rendering the geometry.</param>
        /// <param name="defaultSymbol">The default symbology to use when none is specified by the style.</param>
        /// <param name="clippingEnabled">If rendering clipping is enabled.</param>
        public static void RenderGeometry(Graphics g, Map map, IGeometry feature, VectorStyle style, Bitmap defaultSymbol, bool clippingEnabled)
        {
            Bitmap symbol = style.Symbol;

            switch (feature.GeometryType)
            {
            case "Polygon":
                //NS, 2013-12-02, Add centroid poin inside polygon as guide coordinate for gpshistory
                if ((style.EnableCircleRadius) && (style.EnableOutline))
                {
                    DrawPolygonWithCircle(g, (IPolygon)feature, style.Fill, style.Outline, clippingEnabled, map,
                                          style.CircleLine, style.EnableCircleRadius, style.CircleRadius);
                }
                else
                //NS, 2013-12-02, Add centroid poin inside polygon as guide coordinate for gpshistory
                if ((style.EnableCircleRadius))
                {
                    DrawPolygonWithCircle(g, (IPolygon)feature, style.Fill, null, clippingEnabled, map,
                                          style.CircleLine, style.EnableCircleRadius, style.CircleRadius);
                }
                else
                if (style.EnableOutline)
                {
                    DrawPolygon(g, (IPolygon)feature, style.Fill, style.Outline, clippingEnabled, map);
                }
                else
                {
                    DrawPolygon(g, (IPolygon)feature, style.Fill, null, clippingEnabled, map);
                }
                break;

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

            case "Curve":
                DrawCurve(g, (ILineString)feature, style.Line, map);
                if (style.EnableDashStyle == true)
                {
                    VectorRenderingHelper.DrawDashLineString(g, (ILineString)feature, style.DashLine, map, style.DashReverse);
                }
                break;

            case "LineString":
                //NS, 2014-07-17
                if (!style.IsCurve)
                {
                    DrawLineString(g, (ILineString)feature, style.Line, map);
                }
                else     //NS, 2013-06-26
                {
                    DrawCurve(g, (ILineString)feature, style.Line, map);
                }
                //NS, 2013-09-16
                if (style.EnableDashStyle == true)
                {
                    VectorRenderingHelper.DrawDashLineString(g, (ILineString)feature, style.DashLine, map, style.DashReverse);
                }
                break;

            case "MultiLineString":
                DrawMultiLineString(g, (IMultiLineString)feature, style.Line, map);
                break;

            case "Point":
                if (symbol == null)
                {
                    symbol = defaultSymbol;
                }
                //NS, 2013-10-02, berguna pada saat highlight point....
                if (style.EnableCircleRadius)
                {
                    DrawPointWithCircle(g, (IPoint)feature, symbol, style.SymbolScale, style.SymbolOffset, style.SymbolRotation,
                                        map, true, style.CircleRadius, style.CircleLine);
                }
                DrawPoint(g, (IPoint)feature, symbol, style.SymbolScale,
                          style.SymbolOffset, style.SymbolRotation, map);
                break;

            case "MultiPoint":
                if (symbol == null)
                {
                    symbol = defaultSymbol;
                }
                //NS, 2013-10-02, berguna pada saat highlight point....
                if (style.EnableCircleRadius)
                {
                    VectorRenderingHelper.DrawMultiPointWithCircle(g, (IMultiPoint)feature, symbol, style.SymbolScale,
                                                                   style.SymbolOffset, style.SymbolRotation, map, true, style.CircleRadius, style.CircleLine);
                }
                VectorRenderingHelper.DrawMultiPoint(g, (IMultiPoint)feature, symbol, style.SymbolScale,
                                                     style.SymbolOffset, style.SymbolRotation, map);
                break;

            case "GeometryCollection":
                IGeometryCollection geometryCollection = (IGeometryCollection)feature;
                for (int i = 0; i < geometryCollection.Count; i++)
                {
                    RenderGeometry(g, map, geometryCollection[i], style, defaultSymbol, clippingEnabled);
                }

                break;

            default:
                break;
            }
        }
        /// <summary>
        /// Renders a geometry to the screen depending on the geometry type.
        /// </summary>
        /// <param name="g">The graphics object used to draw geometries.</param>
        /// <param name="map">The map the geometry belongs to and is rendered onto.</param>
        /// <param name="feature">The feature of which his geometry will be rendered.</param>
        /// <param name="style">The style to use when rendering the geometry.</param>
        /// <param name="defaultSymbol">The default symbology to use when none is specified by the style.</param>
        /// <param name="clippingEnabled">If rendering clipping is enabled.</param>
        public static void RenderGeometry(Graphics g, IMap map, IGeometry feature, VectorStyle style, Bitmap defaultSymbol, bool clippingEnabled)
        {
            Bitmap symbol = style.Symbol;

            switch (feature.GeometryType)
            {
            case "Polygon":
                if (style.EnableOutline)
                {
                    DrawPolygon(g, (IPolygon)feature, style.Fill, style.Outline, clippingEnabled, map);
                }
                else
                {
                    DrawPolygon(g, (IPolygon)feature, style.Fill, null, clippingEnabled, map);
                }
                break;

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

            case "LineString":
                DrawLineString(g, (ILineString)feature, style.Line, map);
                break;

            case "MultiLineString":
                DrawMultiLineString(g, (IMultiLineString)feature, style.Line, map);
                break;

            case "Point":
                if (symbol == null)
                {
                    symbol = defaultSymbol;
                }
                DrawPoint(g, (IPoint)feature, symbol, style.SymbolScale,
                          style.SymbolOffset, style.SymbolRotation, map);
                break;

            case "MultiPoint":
                if (symbol == null)
                {
                    symbol = defaultSymbol;
                }
                VectorRenderingHelper.DrawMultiPoint(g, (IMultiPoint)feature, symbol, style.SymbolScale,
                                                     style.SymbolOffset, style.SymbolRotation, map);
                break;

            case "GeometryCollection":
                IGeometryCollection geometryCollection = (IGeometryCollection)feature;
                for (int i = 0; i < geometryCollection.Count; i++)
                {
                    RenderGeometry(g, map, geometryCollection[i], style, defaultSymbol, clippingEnabled);
                }

                break;

            default:
                break;
            }
        }