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

四川地理中心在2011年,后台采用的是ArcGIS发布的Rest服务,但由于进行了Rest扩展开发,无法利用软件直接读取,所以这里给出相关的一些剖析及读取方法。

下面是四川地理信息中心能提供的一些服务,从类型上来讲包括切片、搜索及网络分析,均采用Rest组织风格。

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

1) 规则说明


详情:请见四川地理信息中心网站。

2) 代码实现

继承API可的TiledMapServiceLayer类,派生SCTileMap子类,并对InitializeGetTileUrl方法进行覆盖,后台具体代码及说明如下:

public classSCTileMap : TiledMapServiceLayer

{

privateconststringbaseUrl = "http://www.scgis.net.cn/iMap/iMapServer/NewRest/services/SCTileMap/tile/";

//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/iMapServer/Token/getToken?username=test20110703&password=test20110703&IpAddress=&TimeSpan=100M&st=1302073818076";

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的实现,关于针对搜索服务及网络服务的探讨将放在后续文章中给出。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值