示例#1
0
        private GraphicsPath ToShape(IGeometryCollection gc)
        {
            var shape = new GeometryCollectionGraphicsPath();

            // add components to GC shape
            for (int i = 0; i < gc.NumGeometries; i++)
            {
                var g = gc.GetGeometryN(i);
                shape.Add(ToShape(g));
            }
            return(shape.Path);
        }
        /*
         // Obsolete (slower code)
        private Shape OLDtoShape(Polygon p)
        {
            ArrayList holeVertexCollection = new ArrayList();

            for (int j = 0; j < p.getNumInteriorRing(); j++) {
                holeVertexCollection.add(
                    toViewCoordinates(p.getInteriorRingN(j).getCoordinates()));
            }

            return new PolygonShape(
                toViewCoordinates(p.getExteriorRing().getCoordinates()),
                holeVertexCollection);
        }

        private Coordinate[] toViewCoordinates(Coordinate[] modelCoordinates)
        {
            Coordinate[] viewCoordinates = new Coordinate[modelCoordinates.length];

            for (int i = 0; i < modelCoordinates.length; i++) {
                Point2D point2D = toPoint(modelCoordinates[i]);
                viewCoordinates[i] = new Coordinate(point2D.getX(), point2D.getY());
            }

            return viewCoordinates;
        }
    */

        private GraphicsPath ToShape(IGeometryCollection gc)
        {
            var shape = new GeometryCollectionGraphicsPath();
            // add components to GC shape
            for (int i = 0; i < gc.NumGeometries; i++)
            {
                var g = gc.GetGeometryN(i);
                shape.Add(ToShape(g));
            }
            return shape.Path;
        }