PIE SDK與GeoServer結合說明文檔

 1.  GeoServer簡介

    GeoServer是OpenGIS Web服務器規範的J2EE實現的社區開源項目,利用GeoServer能夠方便的發佈地圖數據,容許用戶對特徵數據進行更新、刪除、插入操做,經過GeoServer能夠容易的在用戶之間迅速共享空間地理信息。它能兼容WMS和 WFS 特性;支持 PostGIS、Shapefile、ArcSDE、Oracle、VPF、MySQL、MapInfo;支持上百種投影;可以將網絡地圖輸出爲 jpeg、gif、png、SVG、KML等格式;支持AJAX 的地圖客戶端OpenLayers。瀏覽器

 

   GeoServer的安裝參考:http://www.javashuo.com/article/p-cpqomzbj-ko.html服務器

   GeoServer發佈WMTS服務參考:網絡

   https://blog.csdn.net/weixin_38843590/article/details/79879317google

 

2.  應用介紹說明

  2.1.  應用場景介紹

    應用項目中常常遇到WebGIS和桌面GIS中共享一份地圖或多個桌面端共享一份地圖,應對這個問題的最優的方案就是把數據發佈成一份地圖服務,經過WMTS地圖服務實現不一樣終端的數據共享。下面咱們介紹如何在PIE中加載GeoServer發佈的地圖服務。url

  2.2.  實現思路介紹

    要在PIE中加載GeoServer地圖服務,能夠經過PIE的自定義瓦片服務接口ICustomerOnlineTiledLayer來完成。要實現它咱們須要知道瓦片的地址,那麼如何找到GeoServer中WMTS服務的瓦片地址呢?下面演示如何在google瀏覽器下得到瓦片的路徑:spa

 

粘貼獲得:http://localhost:8080/geoserver/gwc/service/wmts?layer=PIEServer%3AWorldBaseMap&style=&tilematrixset=EPSG%3A4326&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fpng&TileMatrix=EPSG%3A4326%3A7&TileCol=201&TileRow=44.net

標紅的7表明切片的級別,標紅的201表明切片的列編號,標紅的44表明切片的行編號,修改成對應的標識符爲:3d

http://localhost:8080/geoserver/gwc/service/wmts?layer=PIEServer%3AWorldBaseMap&style=&tilematrixset=EPSG%3A4326&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fpng&TileMatrix=EPSG%3A4326%3A[$Level]&TileCol=[$Column]&TileRow=[$Row]code

 2.3. 核心接口和方法

接口/類orm

方法

說明

ICustomerOnlineTiledLayer

SetTileInfo(TileInfo info);

設置瓦片信息

TileInfo

DPI

切片DPI,通常爲96;

SpatialReference

地圖服務座標系;

Origin

地圖服務切片起始點;

InitialExtent

地圖服務的數據範圍;

FullExtent

地圖服務的全局範圍

Format

切片的格式,通常爲Png;

TileWidth

切片寬度,通常爲256;

TileHeight

切片高度,通常爲256;

LODInfos

切片級別信息;

LODInfo

Level

切片級別編號;(從0開始)

Resolution

該級別分辨率;

Scale

該級別比例尺;

 

2.4. 示例代碼

項目路徑

百度雲盤地址下/PIE示例程序/14.SDK拓展開發/04PIE SDK與GeoServer結合/PIEMapApplication_GeoServer

數據路徑

百度雲盤地址下/PIE示例數據/柵格數據/04.World/World.tif

視頻路徑

百度雲盤地址下/PIE視頻教程/14.SDK拓展開發/ PIE SDK與GeoServer結合.avi

示例代碼

 1 /// <summary>
 2 /// 增長用戶自定義切片服務圖層
 3 /// </summary>
 4 public void AddCustomTiledLayer()
 5 {
 6 // 建立自定義瓦片地圖服務圖層
 7       string url = "http://localhost:8080/geoserver/gwc/service/wmts?layer=PIEServer%3A
 8 WorldBaseMap&style=&tilematrixset=EPSG%3A4326&Service=WMTS&Request=GetTil
 9 e&Version=1.0.0&Format=image%2Fpng&TileMatrix=EPSG%3A4326%3A[$Level]&TileC
10 ol=[$Column]&TileRow=[$Row]";
11       CustomerOnlineTiledLayer layer = new CustomerOnlineTiledLayer(url);
12       layer.Name = "World";
13 
14       // 設置自定義瓦片地圖服務圖層的地圖切片信息
15       PIE.Carto.TileInfo tileInfo = new TileInfo();
16       tileInfo.Format = (PIE.Carto.TileImageFormat)1;
17       tileInfo.DPI = 96;
18       tileInfo.TileWidth = 256;
19       tileInfo.TileHeight = 256;
20       tileInfo.CompressionQuality = 75;
21       tileInfo.LODInfos = new List<LODInfo>();
22       double dResolution = 0.703125;
23       double dScale = 2.95497598570834E8;
24       for (int i = 0; i < 16; ++i)
25       {
26            PIE.Carto.LODInfo lodInfo = new LODInfo();
27            lodInfo.Level = i;
28            lodInfo.Resolution = dResolution / Math.Pow(2.0, i);
29            lodInfo.Scale = dScale / Math.Pow(2.0, i); ;
30            tileInfo.LODInfos.Add(lodInfo);
31       }
32       ISpatialReference spatialReference = SpatialReferenceFactory.CreateSpatialReference(4326);
33       tileInfo.SpatialReference = spatialReference;
34 
35       // 設置自定義瓦片地圖服務圖層的起始點和範圍信息
36       IPoint point = new PIE.Geometry.Point();
37       point.PutCoords(-180, 90);
38       (point as IGeometry).SpatialReference = spatialReference;
39       tileInfo.Origin = point;
40       IEnvelope envelope = new Envelope();
41       envelope.PutCoords(-180, -90, 180, 90);
42       tileInfo.InitialExtent = envelope;
43       tileInfo.FullExtent = envelope;
44       layer.SetTileInfo(tileInfo);
45 
46       // 加載到地圖並刷新
47       m_HookHelper.FocusMap.AddLayer(layer);
48       m_HookHelper.ActiveView.PartialRefresh(ViewDrawPhaseType.ViewAll);
49 }

2.5.  示例截圖

相關文章
相關標籤/搜索