多源在线与离线数据读取二(四川省地理信息中心切片读法)

0
分享 2013-09-13
四川地理中心在2011年,后台采用的是ArcGIS发布的Rest服务,但由于进行了Rest扩展开发,无法利用软件直接读取,所以这里给出相关的一些剖析及读取方法。
下面是四川地理信息中心能提供的一些服务,从类型上来讲包括切片、搜索及网络分析,均采用Rest组织风格。

下面针对切片的相关规则及代码实现给个具体的实现方法:
1) 规则说明

详情:请见四川地理信息中心网站。
2) 代码实现
继承API可的TiledMapServiceLayer类,派生SCTileMap子类,并对Initialize、GetTileUrl方法进行覆盖,后台具体代码及说明如下:
public classSCTileMap : TiledMapServiceLayer
{
privateconststringbaseUrl = "http://www.scgis.net.cn/iMap/i ... 3B%3B

//System.Randomra = new System.Random();
privateconstint WKID= 4326;
//privateconst double baseScale = 3.38E-9 * 2.663;
privateconstdoublebaseScale = 4622333.68;
privatestring tokenStr ="";
publicSCTileMap()
{
//进行页面请求
requestGetToken();
}
public void requestGetToken()
{
stringurl = "http://www.scgis.net.cn/imap/i ... 3B%3B
WebClientclient = new WebClient();
client.DownloadStringCompleted +=ClientDownloadStringCompleted;
client.DownloadStringAsync(newUri(url, UriKind.Absolute));
}
privatevoid ClientDownloadStringCompleted(object sender,DownloadStringCompletedEventArgse)
{
stringresult = e.Result;
tokenStr = result.Split(newchar[] { '{' })[2].Split(newchar[] {'\"'})[3];

setMetaData();
}
public override voidInitialize()
{
}
privatevoid setMetaData()
{
//图层的全图范围
this.FullExtent= new ESRI.ArcGIS.Client.Geometry.Envelope(95.918, 24.898, 110.14, 35.209)
{
SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326)
};

//图层的空间参考
this.SpatialReference=new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326);

//设置切片的信息.每个切片的大小512x512px, 14级
this.TileInfo= new TileInfo()
{
Height = 256,
Width = 256,
Origin = new ESRI.ArcGIS.Client.Geometry.MapPoint(-180, 90) { SpatialReference =new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326) },
Lods = newESRI.ArcGIS.Client.Lod[11]
};

//设置每一级别的分辨率.每一级别的分辨率都是前一个级别的一半
doubleresolution = 0.010998662747496;
for(int i = 0; i < TileInfo.Lods.Length; i++)
{
TileInfo.Lods[i] = newLod() {Resolution = resolution };
resolution /= 2;
}

//调用初始化事件
base.Initialize();
}

//返回指定切片的url
public override stringGetTileUrl(int level,introw, int col)
{
stringURL = baseUrl + (level + 1).ToString() +"/"+ row.ToString() + "/" +col.ToString() + "?token="+this.tokenStr;
returnURL;
}
}

前台代码:
<!--超图本地离线切片读取-->
<!--四川地理信息中心在线服务读取-->
<esri:Map x:Name="MyMap">
<esri:Map.Layers >
<customTiled:SCTileMap ID="sccustommap" x:Name="sc_custommap"/>
</esri:Map.Layers>
</esri:Map>

展现结果:

小结:
利用WebAPI进行相关切片读取比较简单,依照对Silverlight的实现可以进行Flex及Javascript的实现,关于针对搜索服务及网络服务的探讨将放在后续文章中给出。

文章来源:http://blog.csdn.net/esrichinacd/article/details/7595290

0 个评论

要回复文章请先登录注册