通过brutile / sharpmap向地理服务器发送wms请求以加载平铺地图(tiles = true)

时间:2016-11-08 11:56:42

标签: c# vb.net geoserver sharpmap

我想在SharpMap的地图框中加载平铺地图。我有GeoServer并发送WMS请求,但我只收到单个图块地图。 我怎样才能收到多图块地图? 这是我的代码:

    Dim wmsUrl As String = "http://192.168.21.202:8080/geoserver/threem/gwc/service/wms?tiled=true&version=1.1.0"
    Dim layWms As New SharpMap.Layers.WmsLayer("threem_zoom", wmsUrl)
    layWms.AddLayer("threem_zoom")
    layWms.SetImageFormat("image/png")
    layWms.TimeOut = 5000
    layWms.SRID = 4326
    layWms.Version = "1.1.0"
    MapBox1.Map.Layers.Add(layWms)
    MapBox1.PanOnClick = True
    MapBox1.Map.ZoomToExtents()
    MapBox1.Refresh()

3 个答案:

答案 0 :(得分:1)

使用SharpMap的TileLayerAsync可以实现这一点。请参阅TileLayerAsync here的示例。您需要指定合适的切片源。

使用GeoServer的tile = true it looks,您仍然将其作为普通WMS发布,但考虑到标签放置。在这种情况下,你需要像here

这样的东西

或许更好的方法是使用GeoServer将其作为使用TMS,WMTS或WMS-C的适当切片层发布。在这种情况下,您需要通过BruTile的HttpTileSource访问它。

答案 1 :(得分:0)

documentation看起来好像支持简单的WMS图层 - 因此您需要自己处理图块边界的构造并发出多个WMS请求以获得平铺图像。

  

WMS Layer支持目前非常基础。您必须自己解密服务器功能,并在资源属性中指定nessesary图层和其他属性。

答案 2 :(得分:0)

我用这段代码解决了这个问题:

Try
        form1.Mapbox1.Map.Layers.Clear()
        Dim Map As Map = New Map()
        Dim xmlDoc As New XmlDocument()
        If My.Settings.Cache Then
            xmlDoc.Load("http://" & My.Settings.ServerIP & ":" & My.Settings.ServerPort & "/" & My.Settings.ServerName & "/gwc/service/wms?SERVICE=WMS&VERSION=" & My.Settings.WMSVer & "&REQUEST=getcapabilities&TRANSPARENT=TRUE&TILED=true")
        Else
            xmlDoc.Load("http://" & My.Settings.ServerIP & ":" & My.Settings.ServerPort & "/" & My.Settings.ServerName & "/wms?SERVICE=WMS&VERSION=" & My.Settings.WMSVer & "&REQUEST=getcapabilities&TRANSPARENT=TRUE&TILED=true")
        End If
        Dim xDoc = Program.ConvertToXDocument(xmlDoc)
        Dim source As List(Of ITileSource)
        source = WmscTileSource.CreateFromWmscCapabilties((xDoc))
        Dim tileSource = source.FirstOrDefault(Function(x) x.Schema.Name = My.Settings.WorkSapce & ":" & My.Settings.LayerName)
        Dim tileLayer = New TileAsyncLayer(tileSource, My.Settings.WorkSapce & ":" & My.Settings.LayerName) With {.SRID = My.Settings.SRIDNum}
        tileLayer.OnlyRedrawWhenComplete = True
        form1.Mapbox1.Map.Layers.Add(tileLayer)
        form1.Mapbox1.PanOnClick = True
        Dim env = New Envelope(44.0509701, 25.0652748, 63.3556599, 39.796795)
        form1.Mapbox1.Map.ZoomToBox(env)
        form1.Mapbox1.Map.ZoomToExtents()
        form1.Mapbox1.Map.Center = New Coordinate(53.682362, 32.420654)
        form1.Mapbox1.Refresh()
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try