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


C# Map.GetMap方法代码示例

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


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

示例1: 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

示例2: ParseQueryString


//.........这里部分代码省略.........
                    if (fc < 1)
                        fc = 1;
                }
                catch
                {
                    fc = 1;
                }
                //default to text if an invalid format is requested
                string infoFormat = context.Request.Params["INFO_FORMAT"];
                string cqlFilter = null;
                if (context.Request.Params["CQL_FILTER"] != null)
                {
                    cqlFilter = context.Request.Params["CQL_FILTER"];
                }

                string vstr = "";
                string[] requestLayers = context.Request.Params["QUERY_LAYERS"].Split(new[] { ',' });
                if (String.Compare(context.Request.Params["INFO_FORMAT"], "text/json", ignorecase) == 0)
                {
                    vstr = CreateFeatureInfoGeoJSON(map, requestLayers, x, y, fc, cqlFilter);
                    context.Response.ContentType = "text/json";
                }
                else
                {
                    vstr = CreateFeatureInfoPlain(map, requestLayers, x, y, fc, cqlFilter);
                    context.Response.ContentType = "text/plain";
                }
                context.Response.Clear();                
                context.Response.Charset = "windows-1252";
                context.Response.Write(vstr);
                context.Response.Flush();
                context.Response.End();
            }
            else if (String.Compare(context.Request.Params["REQUEST"], "GetMap", ignorecase) == 0) //Map requested
            {
                //Check for required parameters
                if (context.Request.Params["LAYERS"] == null)
                {
                    WmsException.ThrowWmsException("Required parameter LAYERS not specified");
                    return;
                }
                if (context.Request.Params["STYLES"] == null)
                {
                    WmsException.ThrowWmsException("Required parameter STYLES not specified");
                    return;
                }
                if (context.Request.Params["CRS"] == null)
                {
                    WmsException.ThrowWmsException("Required parameter CRS not specified");
                    return;
                }
                else if (context.Request.Params["CRS"] != "EPSG:" + map.Layers[0].TargetSRID)
                {
                    WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidCRS, "CRS not supported");
                    return;
                }
                if (context.Request.Params["BBOX"] == null)
                {
                    WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidDimensionValue,
                                                   "Required parameter BBOX not specified");
                    return;
                }
                if (context.Request.Params["WIDTH"] == null)
                {
                    WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidDimensionValue,
                                                   "Required parameter WIDTH not specified");
开发者ID:lishxi,项目名称:_SharpMap,代码行数:67,代码来源:WmsServer.cs

示例3: 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

示例4: TestMap

        public void TestMap()
        {
            var m = new Map(new Size(1024, 786)) {BackColor = Color.FloralWhite};
            const string samplePath = @"D:\GIS\FileGDB\samples\data\Topo.gdb";

            var p = new FileGdbProvider(samplePath);

            foreach (var fc in p.GetFeatureClasses("\\USA"))
            {
                if (fc.StartsWith("\\USA\\T"))
                    continue;

                Console.WriteLine(fc);
                var pUse = new FileGdbProvider(samplePath) { Table = fc };
                var vl = new VectorLayer("Layer:" + fc, pUse)
                             {
                                 SmoothingMode = SmoothingMode.HighQuality,
                                 Style = {Fill = RandomBrush(), Line = RandomPen()}
                             };
                m.Layers.Add(vl);

                var fds = new FeatureDataSet();
                vl.ExecuteIntersectionQuery(vl.Envelope, fds);
                fds.Tables[0].TableName = fc;
                var res = fds.Tables[0].Rows[0].ItemArray;
                foreach (DataColumn col in fds.Tables[0].Columns)
                    Console.Write(string.Format("{0} [{1}], ", col.ColumnName, col.DataType));
                Console.WriteLine();

                foreach (var item in res)
                    Console.Write(string.Format(CultureInfo.InvariantCulture, "{0}, ", item));
                Console.WriteLine();

                Console.WriteLine(pUse.GetGeometryByID(1));

                var r = pUse.GetFeature(1);
                foreach (var item in r.ItemArray)
                    Console.Write(string.Format(CultureInfo.InvariantCulture, "{0}, ", item));

                Console.WriteLine();
                Console.WriteLine();
            }
            Console.WriteLine();

            p.Dispose();

            m.ZoomToExtents();
            var b = m.GetMap();
            b.Save("fgdb-usa-states.bmp");

            //var fds = new FeatureDataSet();
            //lc.ExecuteIntersectionQuery(m.GetExtents().GetCentroid(), fds);
            //fds.Tables[0].TableName = lc.LayerName;
            //fds.Tables[0].WriteXml(Console.Out);
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:55,代码来源:FileGdbProviderTest.cs

示例5: 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

示例6: 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

示例7: CreateGenericSymbol

        /// <summary>
        /// Method to create a generic symbol for the layer
        /// </summary>
        /// <param name="layer"></param>
        /// <returns></returns>
        private Image CreateGenericSymbol(ILayer layer)
        {
            if (LegendSettings.SymbolSize == Size.Empty)
                return null;

            Image tmp;
            using (var m = new Map(new Size(10*LegendSettings.SymbolSize.Width, 10*LegendSettings.SymbolSize.Height)))
            {
                m.Layers.Add(layer);
                m.ZoomToExtents();
                tmp = m.GetMap();
                //tmp.Save("map.png");
                //System.Diagnostics.Process.Start("map.png");
                m.Layers.Remove(layer);
            }
            
           var res = new Bitmap(LegendSettings.SymbolSize.Width, LegendSettings.SymbolSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
           using (var g = Graphics.FromImage(res))
           {
           		g.DrawImage(tmp, new Rectangle(0, 0, LegendSettings.SymbolSize.Width, LegendSettings.SymbolSize.Height),
           	                 	 new Rectangle(0, 0, tmp.Width, tmp.Height), GraphicsUnit.Pixel);
           }
                   
            return res;
        }
开发者ID:jrmsjorgesilva,项目名称:SharpMap.Rendering.Decorations.Legend,代码行数:30,代码来源:LegendFactory.cs

示例8: ParseQueryString


//.........这里部分代码省略.........
                                        Array.Sort(area, keys);
                                        if (fds.Tables[0].Rows.Count < fc)
                                        {
                                            fc = fds.Tables[0].Rows.Count;
                                        }
                                        for (int k = 0; k < fc; k++)
                                        {
                                            for (int j = 0; j < fds.Tables[0].Rows[keys[k]].ItemArray.Length; j++)
                                            {
                                                vstr = vstr + " '" + fds.Tables[0].Rows[keys[k]].ItemArray[j].ToString() + "'";
                                            }
                                            if ((k + 1) < fc)
                                                vstr = vstr + ",\n";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (found == false)
                    {
                        WmsException.ThrowWmsException(WmsException.WmsExceptionCode.LayerNotDefined,
                                                       "Unknown layer '" + requestLayer + "'");
                        return;
                    }
                }
                context.Response.Clear();
                context.Response.ContentType = "text/plain";
                context.Response.Charset = "windows-1252";
                context.Response.Write(vstr);
                context.Response.Flush();
                context.Response.End();
            }
            else if (String.Compare(context.Request.Params["REQUEST"], "GetMap", ignorecase) == 0) //Map requested
            {
                //Check for required parameters
                if (context.Request.Params["LAYERS"] == null)
                {
                    WmsException.ThrowWmsException("Required parameter LAYERS not specified");
                    return;
                }
                if (context.Request.Params["STYLES"] == null)
                {
                    WmsException.ThrowWmsException("Required parameter STYLES not specified");
                    return;
                }
                if (context.Request.Params["CRS"] == null)
                {
                    WmsException.ThrowWmsException("Required parameter CRS not specified");
                    return;
                }
                else if (context.Request.Params["CRS"] != "EPSG:" + map.Layers[0].SRID)
                {
                    WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidCRS, "CRS not supported");
                    return;
                }
                if (context.Request.Params["BBOX"] == null)
                {
                    WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidDimensionValue,
                                                   "Required parameter BBOX not specified");
                    return;
                }
                if (context.Request.Params["WIDTH"] == null)
                {
                    WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidDimensionValue,
                                                   "Required parameter WIDTH not specified");
开发者ID:lishxi,项目名称:_SharpMap,代码行数:67,代码来源:WmsServer.cs

示例9: Handle

        public override IHandlerResponse Handle(Map map, IContextRequest request)
        {
            WmsParams @params = ValidateParams(request, TargetSrid(map));
            map.BackColor = @params.BackColor;

            // get the image format requested
            ImageCodecInfo imageEncoder = GetEncoderInfo(@params.Format);

            Size size = GetSize(@params);
            map.Size = size;
            Envelope bbox = @params.BBOX;
            double sizeRatio = size.Width / (double)size.Height;
            double bboxRatio = bbox.Width / bbox.Height;
            map.PixelAspectRatio = sizeRatio / bboxRatio;
            map.Center = bbox.Centre;
            map.Zoom = bbox.Width;

            // set Styles for layerNames
            // first, if the request ==  STYLES=, set all the vectorlayers with Themes not null the Theme to the first theme from Themes
            string ptheme = @params.Styles;
            string players = @params.Layers;
            string cqlFilter = @params.CqlFilter;

            if (!String.IsNullOrEmpty(players))
            {
                string[] layerNames = GetLayerNames(map, players);

                // we have a known set of layerNames in request 
                // so we will set each layer to its default theme
                // and disable the layer, layers will be enabled 
                // later as per the request
                foreach (ILayer layer in map.Layers)
                {
                    VectorLayer vectorLayer = layer as VectorLayer;
                    SetDefaultThemeForLayer(vectorLayer);
                    layer.Enabled = false;
                }

                Dictionary<string, string> themeTable = new Dictionary<string, string>();
                BuildThemeLookup(ptheme, layerNames, themeTable);

                // since we have layerNames specified
                // enable only those layerNames
                for (int j = 0; j < layerNames.Length; j++)
                {
                    string layerName = layerNames[j];
                    ILayer layer = GetMapLayerByName(map, layerName);

                    // set layer on/off
                    layer.Enabled = true;

                    // check if a styles have been specified for layers
                    if (themeTable.Count > 0)
                    {
                        string themeName = themeTable[layerName];
                        // do nothing if themeName is empty
                        if (!string.IsNullOrEmpty(themeName))
                        {
                            // is this a vector layer at all
                            VectorLayer vectorLayer = layer as VectorLayer;

                            // does it have several themes to choose from
                            // TODO -> Refactor VectorLayer.Themes to Rendering.Thematics.ThemeList : ITheme
                            if (vectorLayer != null && vectorLayer.Themes != null && vectorLayer.Themes.Count > 0)
                            {
                                // we need to a case invariant comparison for themeName
                                Dictionary<string, ITheme> themeDict = new Dictionary<string, ITheme>(vectorLayer.Themes, new StringComparerIgnoreCase());

                                if (!themeDict.ContainsKey(themeName))
                                    throw new WmsStyleNotDefinedException("Style not advertised for this layer");
                                vectorLayer.Theme = themeDict[themeName];
                            }
                        }
                    }

                    if (!String.IsNullOrEmpty(cqlFilter))
                        ApplyCqlFilter(cqlFilter, layer);
                }

            }
            // render map
            Image img = map.GetMap();
            return new GetMapResponse(img, imageEncoder);
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:84,代码来源:GetMap.cs


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