ImageVerifierCode 换一换
格式:DOCX , 页数:29 ,大小:109.46KB ,
资源ID:3246046      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-3246046.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(SharpMap官方教程.docx)为本站会员(b****2)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

SharpMap官方教程.docx

1、SharpMap官方教程How to get SharpMap source codeV0.9/1.0You have two choices: 1. Download from CodePlex 1. Click on the Source Code tab 2. Click Download in the Latest Version frame. 3. Accept the license agreement and pick a place to save a zip-file of the current version, unpack. 4. Open solution and c

2、ompile. 2. Use subversion client (TortoiseSVN) 1. Get youself a copy of TortoiseSVN and install. 2. Open Explorer, choose place to save your copy of SharpMap, and right-click the mouse. 3. From the context-menu choose checkout and fill in the following url: *) and maybe change the destination path.

3、Username and password are the same as on the codeplex site. 4. Open solution file and compile. *) There are several branches for SharpMap URLDescriptionIntegration of NetTopologySuite v1.7Heavily extended v0.9.5 versionPartial clone of Trunk for adding GeoJSON support (incorporated in Trunk, may be

4、deleted soon?)an experimental branch featuring async rendering and a few other experiments. Avoid(Is currently beeing developed on (DO NOT USE, see belowBugFix branch of user BenjiiIntegration of NTS v1.12 (work in progress)V2.0This version is being developed on Latest project updates 1. Get youself

5、 a copy of TortoiseSVN and install. 2. Open Explorer, choose place to save your copy of SharpMap, and right-click the mouse. 3. From the context-menu choose checkout, fill in the following url: *) and maybe change the destination path. Leave username and password blank. 4. Open solution file and com

6、pile. *)There are several branches for SharpMap URLDescriptionGdal-, Ogr- and BrutileProviderLast edited Dec 20 2011 at 6:20 PMbyFObermaier, version 10 How do I create a map? Initialize the map, add layers, setup style and render it: SharpMap.Map myMap = new SharpMap.Map(new Size(400,300);myMap.Size

7、 = new System.Drawing.Size(300,200); /Set output sizemyMap.MinimumZoom = 100; /Minimum zoom allowedmyMap.BackgroundColor = Color.White; /Set backgroundmyMap.Center = new SharpMap.Geometry.Point(725000, 6180000); /Set center of map/Add PostGIS layer:SharpMap.Layers.VectorLayer myLayer = new SharpMap.

8、Layers.VectorLayer(My layer);string ConnStr = Server=127.0.0.1;Port=5432;UserId=postgres;Password=password;Database=myGisDb;myLayer.DataSource = new SharpMap.Data.Providers.PostGIS(ConnStr, myTable, the_geom, 32632);myLayer.MaxVisible = 40000;myMap.Layers.Add(myLayer);/Render the map/1st possibility

9、: Set zoom level/myMap.Zoom = 1200; /Set zoom level/2nd. possibility: Zoom to extentsmyMap.ZoomToExtents();System.Drawing.Image imgMap = myMap.GetMap();Note:SharpMap.Data.Providers.Postgis is member of the SharpMap.Extensions project.Last edited Mar 9 2010 at 6:24 AMbyFObermaier, version 6 Transform

10、ing between image coordinates and world coordinatesSharpMap has built-in functions to help you transform between image and world coordinates.When the user clicks the map at a given pixel (x,y), you can translate this world coordinates using the ImageToWorld method:SharpMap.Geometries.Point p = myMap

11、.ImageToWorld(new System.Drawing.PointF(x, y); Please note that the value is calculated based on the current zoom and center-values of the myMap Map object.If you want to do the opposite transformation, use WorldToImage:System.Drawing.PointF p = myMap.WorldToImage(new SharpMap.Geometries.Point(34.22

12、5, 175.432); Last edited Aug 24 2007 at 9:24 AMbyrstuven, version 6 Creating a clickable mapSystem.Windows.Forms1. Insert a PictureBox for Windows.Forms. 2. Set the image to your map-instance. Ex.: imgMap.Image = myMap.GetMap(); 3. Set up a MouseClick-event for your PictureBox. 4. Create a MouseClic

13、k-event handler, similar to the one below.protected void imgMap_MouseClick(object sender, MouseClickEventArgs e) /Center the map on the click-point myMap.Center = myMap.ImageToWorld(new System.Drawing.PointF(e.X, e.Y), myMap); /Zoom in 2x myMap.Zoom *= 0.8; /Call function that renders the map and re

14、turns it to the client myImage.Image = myMap.GetMap();There are ready-to-use UserControls (MapImage/MapBox) in the SharpMap.UI project. In addition to zooming functionality they offer tools for querying and panning. ASP.NET1. Insert an for ASP.NET web forms. 2. Set the image to your map-instance. Ex

15、.: imgMap.Image = myMap.GetMap(); 3. Set up a click-event for your ImageButton. 4. Create a click-event handler, similar to the one below.protected void imgMap_Click(object sender, ImageClickEventArgs e) /Center the map on the click-point myMap.Center = myMap.ImageToWorld(new System.Drawing.PointF(e

16、.X, e.Y), myMap); /Zoom in 2x myMap.Zoom *= 0.8; /Call function that renders the map and returns it to the client myImage.Image = myMap.GetMap();Note: You need to store the zoom and center values between requests. This can be done using either ViewState or Session variables. These should be restored

17、 on a postback, and stored when they are changed.Last edited Sep 1 2010 at 6:19 PMbyFObermaier, version 11 How do I add a WMS layer? The WMS Layer support is currently pretty basic. You will have to decipher the server capabilities yourself, and specify the nessesary layers and other properties in t

18、he resource property.Heres an example of how to add the Demis WMS server: string wmsUrl = http:/www2.demis.nl/mapserver/request.asp;SharpMap.Layers.WmsLayer layWms = new SharpMap.Layers.WmsLayer(Demis Map, wmsUrl);layWms.SpatialReferenceSystem = EPSG:4326; /Set spatial reference to use for this serv

19、ice/Add layers (browse the RootLayer/ChildLayers collection to find available/valid layer names)layWms.AddLayer(Bathymetry);layWms.AddLayer(Countries);layWms.AddLayer(Rivers);layWms.AddLayer(Ocean features);/Set image format to request from server/See layWms.OutputFormats array for formats supported

20、 by this WMSlayWms.SetImageFormat(image/png);/Skip rendering the WMS Map if the server couldnt be requested/If set to false such an event would crash the app.layWms.ContinueOnError = true;layWms.TimeOut = 5000; /Set timeout to 5 secondsmyMap.Layers.Add(layWms); /Add layer to your maps layer collecti

21、onYou can get an example of how an image request would look like, by using the GetRequestUrl method. This is also good for debugging the WMS server, since the server often returns an error message on invalid requests.string imageUrl = layWms.GetRequestUrl(new BoundingBox(0,0,360,180), new Size(600,3

22、00);Last edited Aug 9 2006 at 5:46 AMbySharpGIS, version 5 How do I add a shapefile layer? Use the ShapeFile Provider: SharpMap.Layers.VectorLayer layWorld = new SharpMap.Layers.VectorLayer(World);/Specifing true will save the spatial index to a file which will make it load quicker the next timelayW

23、orld.DataSource = new SharpMap.Providers.ShapeFile(C:DataCountries.shp, true); myMap.Layers.Add(layWorld);Last edited Aug 4 2006 at 12:55 AMbySharpGIS, version 6 How to add a PostGIS datasource to the MapThe PostGIS provider is used for rendering geometry data from an PostGreSQL database. You will n

24、eed to install the PostGIS extension in PostGreSQL to use it with SharpMap.To get proper performance, make sure you have applied a spatial index to the geometry column.string connStr = Server=127.0.0.1;Port=5432;User Id=postgres;Password=pass;Database=myMapDB; /Connectionstringstring tablename = Roa

25、ds; /Name of table in databasestring idColumn = gid; /Name of object ID column - MUST be integer!SharpMap.Map myMap = new SharpMap.Map(new System.Drawing.Size(500,250); /Initialize map objectSharpMap.Layers.VectorLayer layRoads= new SharpMap.Layers.VectorLayer(Roads); /Create layerlayRoads.DataSourc

26、e = new SharpMap.Providers.OleDbPoint(connStr, tablename, gid); /Set the datasource to the PostGreSQL tablemyMap.Layers.Add(layRoads); /Add layer to mapmyMap.ZoomToExtents(); /Zoom to extentsImage img = myMap.GetMap(); /Render mapYou can find more help at the PostGIS website on how to load map data

27、into the PostGreSQL database, and how to install PostGIS properly on you database.Note: In earlier versions PostGIS was included in SharpMap, but is now a seperate extension that needs to be added to SharpMap. See PostGISLast edited Aug 4 2006 at 1:16 AMbySharpGIS, version 3 This example is derivied

28、 from the Add a PostGIS layer example.string tablename = Roads; /Name of table in databasestring idColumn = gid; /Name of object ID column - MUST be integer!SharpMap.Map myMap = new SharpMap.Map(new System.Drawing.Size(500,250); /Initialize map objectSharpMap.Layers.VectorLayer layRoads= new SharpMa

29、p.Layers.VectorLayer(Roads); /Create layerlayRoads.DataSource = new SharpMap.Providers.OleDbPoint(connStr, tablename, gid); /Set the datasource to the PostGreSQL table/Set up a road label layerSharpMap.Layers.LabelLayer layRoadLabel = new SharpMap.Layers.LabelLayer(Road labels);layRoadLabel.DataSource = layRoads.DataSource;layRoadLabel.Enabled = true;layRoadLabel.LabelColumn = RoadOfNa

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2