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


C# Map.ZoomToBox方法代码示例

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


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

示例1: ConfigureMap

 public void ConfigureMap(Map map)
 {
     map.Size = this.OutputSize;
     if (this.RealWorldBounds == null)
         map.ZoomToExtents();
     else
         map.ZoomToBox(this.RealWorldBounds);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:8,代码来源:BasicMapRequestConfig.cs

示例2: VectorTile_OverzoomComposite

        public void VectorTile_OverzoomComposite()
        {
            Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
            Map m = new Map(256, 256);
            m.Load(@".\data\layer.xml");

            VectorTile v1 = new VectorTile(1, 0, 0, 256, 256);
            m.ZoomToBox(-20037508.34, 0, 0, 20037508.34);
            m.Render(v1);
            int v1before = v1.GetData().Length;

            VectorTile v2 = new VectorTile(0, 0, 0, 256, 256);
            m.ZoomToBox(-20037508.34, -20037508.34, 20037508.34, 20037508.34);
            m.Render(v2);

            v1.Composite(new List<VectorTile>() { v2 });
            int v1after = v1.GetData().Length;

            //composite bytes will actually be a little bit bigger than 2* original
            //Assert.AreEqual(v1before * 2, v1after);
        }
开发者ID:rouen-sk,项目名称:NET-Mapnik,代码行数:21,代码来源:VectorTileTests.cs

示例3: Handle

 public override IHandlerResponse Handle(Map map, IContextRequest request)
 {
     WmsParams @params = ValidateParams(request, TargetSrid(map));
     map.Size = new Size(@params.Width, @params.Height);
     map.ZoomToBox(@params.BBOX);
     string[] requestLayers = @params.QueryLayers.Split(new[] { ',' });
     AbstractGetFeatureInfoResponse info = CreateFeatureInfo(map,
         requestLayers,
         @params.X, @params.Y,
         @params.FeatureCount,
         @params.CqlFilter,
         _params.PixelSensitivity,
         _params.IntersectDelegate);
     if (_params.Encoding != null)
         info.Charset = _params.Encoding.WebName;
     return info;
 }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:17,代码来源:GetFeatureInfo.cs

示例4: CreateMap

        private Map CreateMap()
        {
            var map = new Map(ClientSize);

            //var p1 = new MatrixRelationProvider(_matrix) { ScaleFactor = 0.1d, ScaleMethod = ScaleMethod.Linear };
            //map.Layers.Add(new VectorLayer(p1.ProviderName, p1)
            //{
            //    Style =
            //        new VectorStyle { Outline = new Pen(Brushes.Black, 1), Fill = new SolidBrush(Color.DarkSalmon), EnableOutline = true }
            //});

            var p2 = new MatrixRelationProvider(_matrix) { ScaleFactor = 0.1d, ScaleMethod = ScaleMethod.Linear, RestrictId = 1 };
            map.Layers.Add(new VectorLayer(p2.ProviderName, p2)
            {
                Style =
                    new VectorStyle { Outline = new Pen(Brushes.Black, 1), Fill = new SolidBrush(Color.BlueViolet), EnableOutline = true }
            });

            var p3 = new MatrixODSumProvider(_matrix, ODMatrixVector.Both) { ScaleFactor = 0.1d, ScaleMethod = ScaleMethod.Linear };
            map.Layers.Add(new VectorLayer(p3.ProviderName, p3)
                               {
                                   Style =
                                       new VectorStyle { Outline = new Pen(Brushes.Black, 1), Fill = new SolidBrush(Color.DarkSeaGreen), EnableOutline = true }
                               });

            var ll = new LabelLayer(string.Format("Label {0}", p3.ProviderName));
            ll.DataSource = p3;
            ll.LabelStringDelegate = d => string.Format("Oid:{0}\nVal:{1:n}", d[0], d[1]);
            ll.Style.Halo = Pens.AliceBlue;
            ll.Style.HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center;
            ll.PriorityColumn = "Value";
            ll.Style.CollisionBuffer = new SizeF(2, 2);
            ll.Style.CollisionDetection = true;
            map.Layers.Add(ll);

            //var extent = map.GetExtents();
            var center = _matrix[1];

            var box = center.EnvelopeInternal;
            box.ExpandBy(25);
            map.ZoomToBox(box);
            return map;
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:43,代码来源:MatrixProviderExample.cs

示例5: LoadMapFromStream

        /// <summary>
        /// Parses a Map from a MapDocument
        /// </summary>
        /// <param name="s">Instance of <see cref="Stream"/></param>
        /// <returns>Map Document accodring to the MapDocument</returns>
        public static Map LoadMapFromStream(Stream s)
        {
            XmlSerializer ser = new XmlSerializer(typeof(MapDefinition));
            MapDefinition md = (MapDefinition)ser.Deserialize(s);

            Map m = new Map();

            if (md.Extent != null)
                m.ZoomToBox(new GeoAPI.Geometries.Envelope(md.Extent.Xmin, md.Extent.Xmax, md.Extent.Ymin, md.Extent.Ymax));

            if (!string.IsNullOrEmpty(md.BackGroundColor))
            {
                m.BackColor = ColorTranslator.FromHtml(md.BackGroundColor);
            }

            m.SRID = md.SRID;

            foreach (var l in md.Layers)
            {
                SharpMap.Layers.ILayer lay = null;
                //WMSLayer?
                if (l is WmsLayer)
                {
                    ICredentials cred = null;
                    if (!string.IsNullOrEmpty((l as WmsLayer).WmsUser))
                        cred = new NetworkCredential((l as WmsLayer).WmsUser, (l as WmsLayer).WmsPassword);

                    SharpMap.Layers.WmsLayer wmsl = new Layers.WmsLayer(l.Name, (l as WmsLayer).OnlineURL, TimeSpan.MaxValue, WebRequest.DefaultWebProxy, cred);
                    if ((l as WmsLayer).WmsLayers != null)
                    {
                        string[] layers = (l as WmsLayer).WmsLayers.Split(',');
                        foreach (var wl in layers)
                        {
                            wmsl.AddLayer(wl);
                        }
                    }
                    else
                    {
                        wmsl.AddChildLayers(wmsl.RootLayer,true);
                    }
                    lay = wmsl;
                }
                //And some simple tiled layers
                else if (l is OsmLayer)
                {
                    lay = new Layers.TileLayer(new BruTile.Web.OsmTileSource(), l.Name);
                }
                else if (l is GoogleLayer)
                {
                    lay = new Layers.TileLayer(new BruTile.Web.GoogleTileSource(BruTile.Web.GoogleMapType.GoogleMap), l.Name);
                }
                else if (l is GoogleSatLayer)
                {
                    lay = new Layers.TileLayer(new BruTile.Web.GoogleTileSource(BruTile.Web.GoogleMapType.GoogleSatellite), l.Name);
                }
                else if (l is GoogleTerrainLayer)
                {
                    lay = new Layers.TileLayer(new BruTile.Web.GoogleTileSource(BruTile.Web.GoogleMapType.GoogleTerrain), l.Name);
                }

                if (lay != null)
                {
                    lay.MinVisible = l.MinVisible;
                    lay.MaxVisible = l.MaxVisible;
                    m.Layers.Add(lay);
                }

            }

            return m;
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:76,代码来源:MapSerialization.cs

示例6: CreateSymbol

 protected override Image CreateSymbol(Size symbolSize, object item)
 {
     var l = (ILayer) item;
     using (var m = new Map(symbolSize))
     {
         m.DisposeLayersOnDispose = false;
         m.Layers.Add(l);
         m.ZoomToBox(l.Envelope);
         return m.GetMap();
     }
 }
开发者ID:jrmsjorgesilva,项目名称:SharpMap.Rendering.Decorations.Legend,代码行数:11,代码来源:AbstractLegendItemFactory.cs

示例7: ParseMap

        /// <summary>
        /// Parses the MAP element
        /// </summary>
        /// <param name="sr"></param>
        /// <param name="m"></param>
        private static void ParseMap(StreamReader sr, Map m, string fileDir)
        {
            string line;
            while ((line = sr.ReadLine()) != null)
            {
                line = TrimFixLine(line);

                string[] parts = ParseLine(line);
                string shapePath = fileDir;
                Envelope env = null;
                if (parts != null && parts.Length > 0)
                {
                    if (string.Compare(parts[0], "ANGLE", true) == 0)
                    {
                        //TODO
                    }
                    else if (string.Compare(parts[0], "SHAPEPATH", true) == 0)
                    {
                        shapePath = parts[1];
                    }
                    else if (string.Compare(parts[0], "EXTENT", true) == 0)
                    {
                        env = new Envelope(Convert.ToDouble(parts[1], CultureInfo.InvariantCulture),
                            Convert.ToDouble(parts[3], CultureInfo.InvariantCulture),
                            Convert.ToDouble(parts[2], CultureInfo.InvariantCulture),
                            Convert.ToDouble(parts[4], CultureInfo.InvariantCulture));
                        m.ZoomToBox(env);
                    }
                    else if (string.Compare(parts[0], "IMAGECOLOR", true) == 0)
                    {
                        m.BackColor = Color.FromArgb(Convert.ToInt32(parts[1]), Convert.ToInt32(parts[2]), Convert.ToInt32(parts[3]));
                    }
                    else if (string.Compare(parts[0], "LAYER", true) == 0)
                    {
                        ParseLayer(sr, m, shapePath);
                    }
                    else if (string.Compare(parts[0], "WEB", true) == 0)
                    {
                        //Just parse it to the END element
                        while ((line = sr.ReadLine()) != null)
                        {
                            line = TrimFixLine(line);
                            parts = ParseLine(line);
                            if (parts != null && parts.Length > 0)
                            {
                                if (string.Compare(parts[0], "END") == 0)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else if (string.Compare(parts[0], "END", true) == 0)
                    {
                        return;
                    }
                }
            }
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:64,代码来源:MapServerMapFileLoader.cs

示例8: CreateMap

 private static Map CreateMap(Size size, ISymbolizer symbolizer)
 {
     var map = new Map(size);
     map.ZoomToBox(new Envelope(0, size.Width, 0, size.Height));
     return map;
 }
开发者ID:jrmsjorgesilva,项目名称:SharpMap.Rendering.Decorations.Legend,代码行数:6,代码来源:DefaultSymbolizerLegendItemFactory.cs

示例9: CreatePolygonalSymbol

        public static Image CreatePolygonalSymbol(Size symbolSize, ISymbolizer sym)
        {
            using (var map = new Map(symbolSize))
            {
                var l = new PolygonalVectorLayer("0", new GeometryProvider(
                    map.Factory.ToGeometry(new Envelope(2, symbolSize.Width - 4, 2, symbolSize.Height - 4))));
                l.Symbolizer = (IPolygonSymbolizer)sym.Clone();

                map.Layers.Add(l);
                map.ZoomToBox(new Envelope(0, symbolSize.Width, 0, symbolSize.Height));

                return map.GetMap();
            }
        }
开发者ID:jrmsjorgesilva,项目名称:SharpMap.Rendering.Decorations.Legend,代码行数:14,代码来源:DefaultSymbolizerLegendItemFactory.cs

示例10: CreatePuntalSymbol

        internal static Image CreatePuntalSymbol(Size symbolSize, ISymbolizer sym)
        {
            using (var map = new Map(symbolSize))
            {
                var l = new PuntalVectorLayer("0", new GeometryProvider(
                    map.Factory.CreatePoint(new Coordinate(symbolSize.Width / 2d, symbolSize.Height / 2d))));
                var s = (IPointSymbolizer)sym.Clone();

                s.Offset = new PointF(0, 0);
                
                if (s.Size.Width > symbolSize.Width)
                    s.Scale = (float)symbolSize.Width / s.Size.Width;
                if (s.Size.Height * s.Scale > symbolSize.Height)
                    s.Scale = (float)symbolSize.Height / s.Size.Height;
                s.Scale *= 0.8f;

                l.Symbolizer = s;

                map.Layers.Add(l);
                map.ZoomToBox(new Envelope(0, symbolSize.Width, 0, symbolSize.Height));

                return map.GetMap();
            }
        }
开发者ID:jrmsjorgesilva,项目名称:SharpMap.Rendering.Decorations.Legend,代码行数:24,代码来源:DefaultSymbolizerLegendItemFactory.cs

示例11: ParseQueryString


//.........这里部分代码省略.........
                if (context.Request.Params["INFO_FORMAT"] == null)
                {
                    WmsException.ThrowWmsException("Required parameter INFO_FORMAT not specified");
                    return;
                }
                //parameters X&Y are not part of the 1.3.0 specification, but are included for backwards compatability with 1.1.1 (OpenLayers likes it when used together with wms1.1.1 services)
                if (context.Request.Params["X"] == null && context.Request.Params["I"] == null)
                {
                    WmsException.ThrowWmsException("Required parameter I not specified");
                    return;
                }
                if (context.Request.Params["Y"] == null && context.Request.Params["J"] == null)
                {
                    WmsException.ThrowWmsException("Required parameter J not specified");
                    return;
                }
                //sets the map size to the size of the client in order to calculate the coordinates of the projection of the client
                try
                {
                    map.Size = new System.Drawing.Size(System.Convert.ToInt16(context.Request.Params["WIDTH"]), System.Convert.ToInt16(context.Request.Params["HEIGHT"]));
                }
                catch
                {
                    WmsException.ThrowWmsException("Invalid parameters for HEIGHT or WITDH");
                    return;
                }
                //sets the boundingbox to the boundingbox of the client in order to calculate the coordinates of the projection of the client
                BoundingBox bbox = ParseBBOX(context.Request.Params["bbox"]);
                if (bbox == null)
                {
                    WmsException.ThrowWmsException("Invalid parameter BBOX");
                    return;
                }
                map.ZoomToBox(bbox);
                //sets the point clicked by the client
                SharpMap.Geometries.Point p = new SharpMap.Geometries.Point();
                Single x = 0;
                Single y = 0;
                //tries to set the x to the Param I, if the client send an X, it will try the X, if both fail, exception is thrown
                if (context.Request.Params["X"] != null)
                    try
                    {
                        x = System.Convert.ToSingle(context.Request.Params["X"]);
                    }
                    catch
                    {
                        WmsException.ThrowWmsException("Invalid parameters for I");
                    }
                if (context.Request.Params["I"] != null)
                    try
                    {
                        x = System.Convert.ToSingle(context.Request.Params["I"]);
                    }
                    catch
                    {
                        WmsException.ThrowWmsException("Invalid parameters for I");
                    }
                //same procedure for J (Y)
                if (context.Request.Params["Y"] != null)
                    try
                    {
                        y = System.Convert.ToSingle(context.Request.Params["Y"]);
                    }
                    catch
                    {
                        WmsException.ThrowWmsException("Invalid parameters for I");
开发者ID:lishxi,项目名称:_SharpMap,代码行数:67,代码来源:WmsServer.cs

示例12: ZoomToBox_WithAspectCorrection

 public void ZoomToBox_WithAspectCorrection()
 {
     Map map = new Map(new System.Drawing.Size(400, 200));
     map.ZoomToBox(GeometryFactory.CreateEnvelope(10, 20, 100, 180));
     Assert.AreEqual(GeometryFactory.CreateCoordinate(15, 140), map.Center);
     Assert.AreEqual(160d, map.Zoom);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:7,代码来源:MapTest.cs

示例13: ConfigureMap

        public void ConfigureMap(Map map)
        {
            if (WmsMode == WmsMode.Capabilites)
                return;


            if (this.Crs != "EPSG:" + map.Layers[0].SRID.ToString())
            {
                WmsException.ThrowWmsException(WmsExceptionCode.InvalidCRS, "CRS not supported");
            }


            map.Size = this.OutputSize;
            map.BackColor = this.BackgroundColor;
            map.ZoomToBox(this.RealWorldBounds);

            foreach (ILayer l in map.Layers)
            {
                l.Enabled = false;
            }

            foreach (string layerName in this.EnabledLayerNames)
                map.GetLayerByName(layerName).Enabled = true;


        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:26,代码来源:WmsMapRequestConfig.cs

示例14: lock

        void ILayer.Render(Graphics g, Map map)
        {
            // We don't need to regenerate the tiles
            if (map.Envelope.Equals(_lastViewport) && _numPendingDownloads == 0)
            {
                g.DrawImage(_bitmap, Point.Empty);
                return;
            }

            // Create a backbuffer
            lock (_renderLock)
            {
                if (_bitmap == null || _bitmap.Size != map.Size)
                {
                    _bitmap = new Bitmap(map.Size.Width, map.Size.Height, PixelFormat.Format32bppArgb);
                    using (var tmpGraphics = Graphics.FromImage(_bitmap))
                        tmpGraphics.Clear(Color.Transparent);
                }
            }
            // Save the last viewport
            _lastViewport = map.Envelope;

            // Cancel old rendercycle
            ((ITileAsyncLayer)this).Cancel();

            var mapViewport = map.Envelope;
            var mapSize = map.Size;

            var mapColumnWidth = _cellSize.Width+_cellBuffer.Width;
            var mapColumnHeight = _cellSize.Height + _cellBuffer.Width;
            var columns = (int)Math.Ceiling((double) mapSize.Width/mapColumnWidth);
            var rows = (int) Math.Ceiling((double) mapSize.Height/mapColumnHeight);

            var renderMapSize = new Size(columns * _cellSize.Width + _cellBuffer.Width, 
                                         rows * _cellSize.Height + _cellBuffer.Height);
            var horizontalFactor = (double) renderMapSize.Width/mapSize.Width;
            var verticalFactor = (double) renderMapSize.Height/mapSize.Height;

            var diffX = 0.5d*(horizontalFactor*mapViewport.Width - mapViewport.Width);
            var diffY = 0.5d*(verticalFactor*mapViewport.Height-mapViewport.Height);

            var totalRenderMapViewport = mapViewport.Grow(diffX, diffY);
            var columnWidth = totalRenderMapViewport.Width/columns;
            var rowHeight = totalRenderMapViewport.Height/rows;

            var rmdx = (int)((mapSize.Width-renderMapSize.Width) * 0.5f);
            var rmdy = (int)((mapSize.Height - renderMapSize.Height) * 0.5f);

            var tileSize = Size.Add(_cellSize, Size.Add(_cellBuffer, _cellBuffer));

            var miny = totalRenderMapViewport.MinY;
            var pty = rmdy + renderMapSize.Height - tileSize.Height;

            for (var i = 0; i < rows; i ++)
            {
                var minx = totalRenderMapViewport.MinX;
                var ptx = rmdx;
                for (var j = 0; j < columns; j++)
                {
                    var tmpMap = new Map(_cellSize);
                    
                    tmpMap.Layers.Add(_baseLayer);
                    tmpMap.DisposeLayersOnDispose = false;
                    tmpMap.ZoomToBox(new Envelope(minx, minx + columnWidth, miny, miny + rowHeight));

                    var cancelToken = new System.Threading.CancellationTokenSource();
                    var token = cancelToken.Token;
                    var pt = new Point(ptx, pty);
                    var t = new System.Threading.Tasks.Task(delegate
                    {
                        if (token.IsCancellationRequested)
                            token.ThrowIfCancellationRequested();

                        var res = RenderCellOnThread(token, pt, tmpMap);
                        if (res)
                        {
                            System.Threading.Interlocked.Decrement(ref _numPendingDownloads);
                            var e = DownloadProgressChanged;
                            if (e != null)
                                e(_numPendingDownloads);
                        }

                    }, token);
                    var dt = new RenderTask {CancellationToken = cancelToken, Task = t};
                    lock (_currentTasks)
                    {
                        _currentTasks.Add(dt);
                        _numPendingDownloads++;
                    }
                    t.Start();
                    minx += columnWidth;
                    ptx += _cellSize.Width;
                }
                miny += rowHeight;
                pty -= _cellSize.Height;
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:97,代码来源:AsyncLayerProxyLayer.cs

示例15: CreateLinealSymbol

        internal static Image CreateLinealSymbol(Size symbolSize, ISymbolizer sym)
        {
            using (var map = new Map(symbolSize))
            {
                var l = new LinealVectorLayer("0", new GeometryProvider(
                    map.Factory.CreateLineString(new[] { new Coordinate(2, 2), new Coordinate(8, 12), new Coordinate(12, 11), new Coordinate(22, 2) })));
                l.Symbolizer = (ILineSymbolizer)sym.Clone();

                map.Layers.Add(l);
                map.ZoomToBox(new Envelope(0, symbolSize.Width, 0, symbolSize.Height));

                return map.GetMap();
            }
        }
开发者ID:jrmsjorgesilva,项目名称:SharpMap.Rendering.Decorations.Legend,代码行数:14,代码来源:DefaultSymbolizerLegendItemFactory.cs


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