基於SharpMap擴充程式開發執行個體

來源:互聯網
上載者:User

SharpMap是基於.Net平台開發的GIS地圖渲染組件。在SharpMap的內部設計了基於OGC 標準的幾何模型 構架,設計了IProvider策略模式的多源向量地圖資料配接器介面,地圖要素渲染的底層主要通過幾何變 換將Geometry轉換為.Net支援的幾何模型如System.Drawing.Point、System.Drawing.Rectangle、 System.Drawing.Drawing2D.GraphicsPath等,然後調用System.Drawing.Graphics類的Draw方法實現地圖 要素的繪製。在SharpMap內部由於沒有設計Symbol的構架,因此,對於需要開發真正的GIS系統,需要封 裝Symbol架構,以便實現專題渲染和地圖符號庫。

SharpMap為我們提供了GIS系統最基本的功能集合,如地圖可視化、空間查詢等功能,因此我們可以利 用SharpMap提供的部分功能為我們在.Net平台上實現地圖可視化提供支援,而不需要藉助一些商業組件。 本文就將簡單的介紹一些基於SharpMap實現部分程式的程式碼範例,希望對研究開源的朋友有所啟示和協助 。註:我已經對SharpMap部分Bug做了修改,重新設計了系統的構架,也新開發了一些新的模組。這些都 將在以後的文章中有所闡述。

基於Jackey.Framework開發Windows應用程式樣本

//初始化代碼,請在表單裝載事件中調用該方法。private void init()        {            //Set buddy control.            this.tocControl1.MapControl = this.mapControl1;            //create a vector layer and set the default renderer.            SharpMap.Layers.VectorLayer layCity=new SharpMap.Layers.VectorLayer("City");            layCity.DataSource=new SharpMap.Data.Providers.ShapeFileProvider(@"D:"ArcGIS"DeveloperKit"SamplesNET"data"GulfOfStLawrence"data"Can_Mjr_Cities.shp");            ((SharpMap.Rendering.SimpleFeatureRenderer)layCity.Renderer).Symbol=new SharpMap.Symbols.MarkerSymbol(SharpMap.Symbols.SymbolType.Circle,Color.Blue,10f);            //create a vector layer and set the default renderer.            SharpMap.Layers.VectorLayer layRoad = new SharpMap.Layers.VectorLayer("Road");            layRoad.DataSource = new SharpMap.Data.Providers.ShapeFileProvider(@"D:"ArcGIS"DeveloperKit"SamplesNET"data"GulfOfStLawrence"data"mjrroads.shp");            ((SharpMap.Rendering.SimpleFeatureRenderer)layRoad.Renderer).Symbol = new SharpMap.Symbols.LineSymbol(Color.Green, 2f);            //create a vector layer and set the default renderer.            SharpMap.Layers.VectorLayer layCoasts = new SharpMap.Layers.VectorLayer("Coasts");            layCoasts.DataSource = new SharpMap.Data.Providers.ShapeFileProvider(@"D:"ArcGIS"DeveloperKit"SamplesNET"data"GulfOfStLawrence"data"Coasts.shp");            ((SharpMap.Rendering.SimpleFeatureRenderer)layCoasts.Renderer).Symbol = new SharpMap.Symbols.FillSymbol(Color.LightCyan);            //add the layer to the map            this.mapControl1.Map.Layers.Add(layCoasts);            this.mapControl1.Map.Layers.Add(layRoad);            this.mapControl1.Map.Layers.Add(layCity);            //zoom the map to the full extent            this.mapControl1.ZoomToFullExtent();        }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.