当前位置: 首页>>代码示例>>C#>>正文


C# MapArgs.ProjToPixel方法代码示例

本文整理汇总了C#中DotSpatial.Controls.MapArgs.ProjToPixel方法的典型用法代码示例。如果您正苦于以下问题:C# MapArgs.ProjToPixel方法的具体用法?C# MapArgs.ProjToPixel怎么用?C# MapArgs.ProjToPixel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotSpatial.Controls.MapArgs的用法示例。


在下文中一共展示了MapArgs.ProjToPixel方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawRegions

 /// <summary>
 /// This will draw any features that intersect this region.  To specify the features
 /// directly, use OnDrawFeatures.  This will not clear existing buffer content.
 /// For that call Initialize instead.
 /// </summary>
 /// <param name="args">A GeoArgs clarifying the transformation from geographic to image space</param>
 /// <param name="regions">The geographic regions to draw</param>
 public void DrawRegions(MapArgs args, List<Extent> regions)
 {
     List<Rectangle> clipRects = args.ProjToPixel(regions);
     for (int i = clipRects.Count - 1; i >= 0; i--)
     {
         if (clipRects[i].Width != 0 && clipRects[i].Height != 0) continue;
         regions.RemoveAt(i);
         clipRects.RemoveAt(i);
     }
     DrawWindows(args, regions, clipRects);
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:18,代码来源:MapImageLayer.cs

示例2: BuildPaths

        private void BuildPaths(MapArgs e, IEnumerable<int> indices, out List<GraphicsPath> paths)
        {
            paths = new List<GraphicsPath>();
            Extent drawExtents = e.GeographicExtents;
            Rectangle clipRect = e.ProjToPixel(e.GeographicExtents);
            SoutherlandHodgman shClip = new SoutherlandHodgman(clipRect);

            List<GraphicsPath> graphPaths = new List<GraphicsPath>();
            Dictionary<FastDrawnState, GraphicsPath> borders = new Dictionary<FastDrawnState, GraphicsPath>();
            for (int selectState = 0; selectState < 2; selectState++)
            {
                foreach (IPolygonCategory category in Symbology.Categories)
                {
                    FastDrawnState state = new FastDrawnState(selectState == 1, category);

                    GraphicsPath border = new GraphicsPath();
                    borders.Add(state, border);
                    graphPaths.Add(border);
                }
            }

            paths.AddRange(graphPaths);

            List<ShapeRange> shapes = DataSet.ShapeIndices;
            double[] vertices = DataSet.Vertex;

            if (ProgressReportingEnabled)
            {
                ProgressMeter = new ProgressMeter(ProgressHandler, "Building Paths", indices.Count());
            }

            if (!DrawnStatesNeeded)
            {
                FastDrawnState state = new FastDrawnState(false, Symbology.Categories[0]);

                foreach (int shp in indices)
                {
                    if (ProgressReportingEnabled) ProgressMeter.Next();
                    ShapeRange shape = shapes[shp];
                    if (!shape.Extent.Intersects(e.GeographicExtents)) return;
                    if (shp >= shapes.Count) return;
                    if (!borders.ContainsKey(state)) return;

                    BuildPolygon(vertices, shapes[shp], borders[state], e, drawExtents.Contains(shape.Extent) ? null : shClip);
                }
            }
            else
            {
                FastDrawnState[] states = DrawnStates;
                foreach (GraphicsPath borderPath in borders.Values)
                {
                    if (borderPath != null)
                    {
                        borderPath.FillMode = FillMode.Winding;
                    }
                }

                foreach (int shp in indices)
                {
                    if (ProgressReportingEnabled) ProgressMeter.Next();
                    if (shp >= shapes.Count) return;
                    if (shp >= states.Length)
                    {
                        AssignFastDrawnStates();
                        states = DrawnStates;
                    }
                    if (states[shp].Visible == false) continue;
                    ShapeRange shape = shapes[shp];
                    if (!shape.Extent.Intersects(e.GeographicExtents)) continue;
                    if (drawExtents.Contains(shape.Extent))
                    {
                        FastDrawnState state = states[shp];
                        if (!borders.ContainsKey(state)) continue;
                        BuildPolygon(vertices, shapes[shp], borders[state], e, null);
                    }
                    else
                    {
                        FastDrawnState state = states[shp];
                        if (!borders.ContainsKey(state)) continue;
                        BuildPolygon(vertices, shapes[shp], borders[state], e, shClip);
                    }
                }
            }
            if (ProgressReportingEnabled) ProgressMeter.Reset();
        }
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:85,代码来源:MapPolygonLayer.cs

示例3: DrawRegions

 /// <summary>
 /// This will draw any features that intersect this region.  To specify the features
 /// directly, use OnDrawFeatures.  This will not clear existing buffer content.
 /// For that call Initialize instead.
 /// </summary>
 /// <param name="args">A GeoArgs clarifying the transformation from geographic to image space</param>
 /// <param name="regions">The geographic regions to draw</param>
 public virtual void DrawRegions(MapArgs args, List<Extent> regions)
 {
     // First determine the number of features we are talking about based on region.
     List<Rectangle> clipRects = args.ProjToPixel(regions);
     if (EditMode)
     {
         List<IFeature> drawList = new List<IFeature>();
         foreach (Extent region in regions)
         {
             if (region != null)
             {
                 // Use union to prevent duplicates.  No sense in drawing more than we have to.
                 drawList = drawList.Union(DataSet.Select(region)).ToList();
             }
         }
         DrawFeatures(args, drawList, clipRects, true);
     }
     else
     {
         List<int> drawList = new List<int>();
         List<ShapeRange> shapes = DataSet.ShapeIndices;
         for (int shp = 0; shp < shapes.Count; shp++)
         {
             foreach (Extent region in regions)
             {
                 if (!shapes[shp].Extent.Intersects(region)) continue;
                 drawList.Add(shp);
                 break;
             }
         }
         DrawFeatures(args, drawList, clipRects, true);
     }
 }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:40,代码来源:MapLineLayer.cs

示例4: FromBruTileExtent

        /*
        private static Extent FromBruTileExtent(BruTile.Extent extent)
        {
            return new Extent(extent.MinX, extent.MinY, extent.MaxX, extent.MaxY);
        }
         */
        /// <summary>
        /// This draws content from the specified geographic regions onto the specified graphics
        /// object specified by MapArgs.
        /// </summary>
        public void DrawRegions(MapArgs args, List<Extent> regions)
        {
            System.Windows.Threading.Dispatcher dispatcher = System.Windows.Application.Current.Dispatcher;
            BruTile.Extent extent = ToBrutileExtent(args.GeographicExtents);
            double pixelSize = extent.Width / args.ImageRectangle.Width;

            int level = Utilities.GetNearestLevel(TileSource.Schema.Resolutions, pixelSize);
            IList<TileInfo> tiles = TileSource.Schema.GetTilesInView(extent, level);

            IList<WaitHandle> waitHandles = new List<WaitHandle>();

            foreach (TileInfo info in tiles)
            {
                if (TileCache.Find(info.Index) != null) continue;
                AutoResetEvent waitHandle = new AutoResetEvent(false);
                waitHandles.Add(waitHandle);
                ThreadPool.QueueUserWorkItem(GetTileOnThread,
                                             new object[] { TileSource.Provider, info, TileCache, waitHandle });
            }

                foreach (WaitHandle handle in waitHandles)
                    handle.WaitOne();

                foreach (TileInfo info in tiles)
                {
                    using (Image bitmap = Image.FromStream(new MemoryStream(TileCache.Find(info.Index))))
                    {
                        PointF min = args.ProjToPixel(new Coordinate(info.Extent.MinX, info.Extent.MinY));
                        PointF max = args.ProjToPixel(new Coordinate(info.Extent.MaxX, info.Extent.MaxY));

                        min = new PointF((float)Math.Round(min.X), (float)Math.Round(min.Y));
                        max = new PointF((float)Math.Round(max.X), (float)Math.Round(max.Y));

                        args.Device.DrawImage(bitmap,
                                    new Rectangle((int)min.X, (int)max.Y, (int)(max.X - min.X), (int)(min.Y - max.Y)),
                                    0, 0, TileSource.Schema.Width, TileSource.Schema.Height,
                                    GraphicsUnit.Pixel);

                    }

                }
        }
开发者ID:ChampsyGnom,项目名称:GeoPat,代码行数:52,代码来源:BruTileLayer.cs

示例5: DrawRegions

 /// <summary>
 /// This will draw any features that intersect this region.  To specify the features
 /// directly, use OnDrawFeatures.  This will not clear existing buffer content.
 /// For that call Initialize instead.
 /// </summary>
 /// <param name="args">A GeoArgs clarifying the transformation from geographic to image space</param>
 /// <param name="regions">The geographic regions to draw</param>
 public virtual void DrawRegions(MapArgs args, List<Extent> regions)
 {
     List<Rectangle> clipRects = args.ProjToPixel(regions);
     if (EditMode)
     {
         List<IFeature> drawList = new List<IFeature>();
         drawList = regions.Where(region => region != null).Aggregate(drawList, (current, region) => current.Union(DataSet.Select(region)).ToList());
         DrawFeatures(args, drawList, clipRects, true);
     }
     else
     {
         List<int> drawList = new List<int>();
         List<ShapeRange> shapes = DataSet.ShapeIndices;
         for (int shp = 0; shp < shapes.Count; shp++)
         {
             foreach (Extent region in regions)
             {
                 if (!shapes[shp].Extent.Intersects(region)) continue;
                 drawList.Add(shp);
                 break;
             }
         }
         DrawFeatures(args, drawList, clipRects, true);
     }
 }
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:32,代码来源:MapPolygonLayer.cs

示例6: DrawRegions

 /// <summary>
 /// This will draw any features that intersect this region.  To specify the features
 /// directly, use OnDrawFeatures.  This will not clear existing buffer content.
 /// For that call Initialize instead.
 /// </summary>
 /// <param name="args">A GeoArgs clarifying the transformation from geographic to image space</param>
 /// <param name="regions">The geographic regions to draw</param>
 public void DrawRegions(MapArgs args, List<Extent> regions)
 {
     List<Rectangle> clipRects = args.ProjToPixel(regions);
     DrawWindows(args, regions, clipRects);
 }
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:12,代码来源:MapRasterLayer.cs

示例7: DrawRegions

        /// <summary>
        /// This will draw any features that intersect this region.  To specify the features
        /// directly, use OnDrawFeatures.  This will not clear existing buffer content.
        /// For that call Initialize instead.
        /// </summary>
        /// <param name="args">A GeoArgs clarifying the transformation from geographic to image space</param>
        /// <param name="regions">The geographic regions to draw</param>
        public virtual void DrawRegions(MapArgs args, List<Extent> regions)
        {
            // First determine the number of features we are talking about based on region.
            var clipRects = args.ProjToPixel(regions);

            var drawList = new List<int>();
            for (var shp = 0; shp < DataSet.Count; shp++)
            {
                var pointExtent = DataSet.GetFeatureExtent(shp);
                if (regions.Any(pointExtent.Intersects))
                {
                    drawList.Add(shp);
                }
            }
            DrawFeatures(args, drawList, clipRects, true);
        }
开发者ID:hanchao,项目名称:DotSpatial,代码行数:23,代码来源:MapPointLayer.cs

示例8: DrawRegions

 /// <summary>
 /// This will draw any features that intersect this region.  To specify the features
 /// directly, use OnDrawFeatures.  This will not clear existing buffer content.
 /// For that call Initialize instead.
 /// </summary>
 /// <param name="args">A GeoArgs clarifying the transformation from geographic to image space</param>
 /// <param name="regions">The geographic regions to draw</param>
 public void DrawRegions(MapArgs args, List<Extent> regions)
 {
     if (FeatureSet == null) return;
     if (FeatureSet.IndexMode)
     {
         // First determine the number of features we are talking about based on region.
         List<int> drawIndices = new List<int>();
         foreach (Extent region in regions)
         {
             if (region != null)
             {
                 // We need to consider labels that go off the screen.  figure a region
                 // that is larger.
                 Extent sur = region.Copy();
                 sur.ExpandBy(region.Width, region.Height);
                 // Use union to prevent duplicates.  No sense in drawing more than we have to.
                 drawIndices = drawIndices.Union(FeatureSet.SelectIndices(sur)).ToList();
             }
         }
         List<Rectangle> clips = args.ProjToPixel(regions);
         DrawFeatures(args, drawIndices, clips, true);
     }
     else
     {
         // First determine the number of features we are talking about based on region.
         List<IFeature> drawList = new List<IFeature>();
         foreach (Extent region in regions)
         {
             if (region != null)
             {
                 // We need to consider labels that go off the screen.  figure a region
                 // that is larger.
                 Extent r = region.Copy();
                 r.ExpandBy(region.Width, region.Height);
                 // Use union to prevent duplicates.  No sense in drawing more than we have to.
                 drawList = drawList.Union(FeatureSet.Select(r)).ToList();
             }
         }
         List<Rectangle> clipRects = args.ProjToPixel(regions);
         DrawFeatures(args, drawList, clipRects, true);
     }
 }
开发者ID:nikson898,项目名称:dot-spatial,代码行数:49,代码来源:MapLabelLayer.cs

示例9: DrawTile

        private void DrawTile(MapArgs args, TileInfo info, Resolution resolution, byte[] buffer, TileReprojector tr = null)
        {
            if (buffer == null || buffer.Length == 0)
                return;

            tr = tr ?? new TileReprojector(args, _projection, _targetProjection);

            using (var bitmap = (Bitmap)Image.FromStream(new MemoryStream(buffer)))
            {
                var inWorldFile = new Reprojection.WorldFile(resolution.UnitsPerPixel, 0, 
                                                0, -resolution.UnitsPerPixel,
                                                info.Extent.MinX, info.Extent.MaxY);

                Reprojection.WorldFile outWorldFile;
                Bitmap outBitmap;


                tr.Reproject(inWorldFile, bitmap, out outWorldFile, out outBitmap);
                if (outWorldFile == null) return;

                var lt = args.ProjToPixel(outWorldFile.ToGround(0, 0));
                var rb = args.ProjToPixel(outWorldFile.ToGround(outBitmap.Width, outBitmap.Height));
                var rect = new Rectangle(lt, Size.Subtract(new Size(rb), new Size(lt)));

                args.Device.DrawImage(outBitmap, rect, 0, 0, outBitmap.Width, outBitmap.Height,
                    GraphicsUnit.Pixel, _imageAttributes);

                if (outBitmap != bitmap) outBitmap.Dispose();
                if (FrameTile)
                {
                    if (FramePen != null)
                        args.Device.DrawRectangle(FramePen, rect);
                }
            }
        }
开发者ID:haoas,项目名称:DotSpatial.Plugins,代码行数:35,代码来源:BruTileLayer.cs

示例10: Initialize

        /// <summary>
        /// Instructs the map frame to draw content from the specified regions to the buffer..
        /// </summary>
        /// <param name="regions">The regions to initialize.</param>
        public virtual void Initialize(List<Extent> regions)
        {
            bool setView = false;
            if (_backBuffer == null)
            {
                _backBuffer = CreateBuffer();

                //set the view
                setView = true;
            }

            Graphics bufferDevice = Graphics.FromImage(_backBuffer);
            MapArgs args = new MapArgs(ClientRectangle, ViewExtents, bufferDevice);
            GraphicsPath gp = new GraphicsPath();
            foreach (Extent region in regions)
            {
                if (region == null) continue;
                Rectangle rect = args.ProjToPixel(region);
                gp.StartFigure();
                gp.AddRectangle(rect);
            }
            bufferDevice.Clip = new Region(gp);

            // Draw the background color
            if (null != _parent) bufferDevice.Clear(_parent.BackColor);
            else bufferDevice.Clear(Color.White);

            // First draw all the vector content
            foreach (IMapLayer layer in Layers)
            {
                if (layer.VisibleAtExtent(ViewExtents)) layer.DrawRegions(args, regions);
            }
            // Then
            MapLabelLayer.ExistingLabels = new List<RectangleF>();
            foreach (IMapLayer layer in Layers)
            {
                InitializeLabels(regions, args, layer);
            }

            // First draw all the vector content
            foreach (IMapLayer layer in DrawingLayers)
            {
                if (layer.VisibleAtExtent(ViewExtents)) layer.DrawRegions(args, regions);
            }

            if (_buffer != null && _buffer != _backBuffer) _buffer.Dispose();
            _buffer = _backBuffer;
            if(setView)
                _view = _backView;
            bufferDevice.Clip = new Region(ImageRectangle);
            gp.Dispose();
            List<Rectangle> rects = args.ProjToPixel(regions);
            OnBufferChanged(this, new ClipArgs(rects));
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:58,代码来源:MapFrame.cs


注:本文中的DotSpatial.Controls.MapArgs.ProjToPixel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。