コード例 #1
0
ファイル: MapLineLayer.cs プロジェクト: rprouse/DotSpatial
        /// <summary>
        /// Adds the given points to the given path.
        /// </summary>
        /// <param name="path">Path the points get added to.</param>
        /// <param name="args">MapArgs used for clipping.</param>
        /// <param name="extent">Extent of the feature used for clipping.</param>
        /// <param name="points">Points that get added to the path.</param>
        /// <param name="clipRect">The clipping rectangle.</param>
        private static void AddLineStringToPath(GraphicsPath path, MapArgs args, Extent extent, List <double[]> points, Rectangle clipRect)
        {
            List <List <double[]> > multiLinestrings;

            if (!extent.Within(args.GeographicExtents))
            {
                multiLinestrings = CohenSutherland.ClipLinestring(points, clipRect.Left, clipRect.Top, clipRect.Right, clipRect.Bottom);
            }
            else
            {
                multiLinestrings = new List <List <double[]> >
                {
                    points
                };
            }

            foreach (List <double[]> linestring in multiLinestrings)
            {
                var intPoints = DuplicationPreventer.Clean(linestring).ToArray();
                if (intPoints.Length < 2)
                {
                    continue;
                }

                path.StartFigure();
                path.AddLines(intPoints);
            }
        }
コード例 #2
0
        internal static void BuildLineString(GraphicsPath path, double[] vertices, ShapeRange shpx, MapArgs args, Rectangle clipRect)
        {
            double minX = args.MinX;
            double maxY = args.MaxY;
            double dx   = args.Dx;
            double dy   = args.Dy;

            for (int prt = 0; prt < shpx.Parts.Count; prt++)
            {
                PartRange prtx   = shpx.Parts[prt];
                int       start  = prtx.StartIndex;
                int       end    = prtx.EndIndex;
                var       points = new List <double[]>(end - start + 1);

                for (int i = start; i <= end; i++)
                {
                    var pt = new[]
                    {
                        (vertices[i * 2] - minX) * dx,
                        (maxY - vertices[i * 2 + 1]) * dy
                    };
                    points.Add(pt);
                }

                List <List <double[]> > multiLinestrings;
                if (!shpx.Extent.Within(args.GeographicExtents))
                {
                    multiLinestrings = CohenSutherland.ClipLinestring(points, clipRect.Left, clipRect.Top,
                                                                      clipRect.Right, clipRect.Bottom);
                }
                else
                {
                    multiLinestrings = new List <List <double[]> > {
                        points
                    };
                }

                foreach (List <double[]> linestring in multiLinestrings)
                {
                    var intPoints = DuplicationPreventer.Clean(linestring).ToArray();
                    if (intPoints.Length < 2)
                    {
                        continue;
                    }

                    path.StartFigure();
                    path.AddLines(intPoints);
                }
            }
        }