您的位置:首页 > 其它

ArcGIS Runtime for .Net Quartz开发探秘(三):承接来自GIS服务器的服务

2017-09-08 15:30 459 查看
在上一篇博客中,我们已经在程序中添加了两个服务,一个是切片地图服务,另一个是三维场景服务。

这篇博客则会从整体上介绍几种常用服务的使用方式。

先解释两个名词:服务、图层

服务:服务器对外提供功能的单元

图层:应用程序组织要素的单元

服务和图层,表现在程序中是这样的:

<esri:ArcGISSceneLayer Name="BuildingsLayer" Source="http://scene.arcgis.com/arcgis/rest/services/Hosted/Buildings_Brest/SceneServer/layers/0"/>

其中http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer是服务,ArcGISTiledLayer是图层。

动态地图服务&切片地图服务

动态地图服务:用户浏览地图的时候由Server临时绘制地图的一种服务。

切片地图服务:与动态地图服务不同,切片是事先绘制好缓存起来的,而动态地图服务则是在调用时,读取地图数据后临时绘制的。

MapService:在ArcGIS Server的服务中,一个MapService地图服务可能同时包含上面两种服务的服务能力(动态地图服务和切片地图服务)。通过各种终端发布至ArcGIS Server的MapService,默认会开启动态地图服务能力,但是不一定有切片地图服务能力。作为移动端开发人员,拿到的URL在结构上是看不出是否具有切片地图服务能力的,只能通过在浏览器上输入URL,在服务详情中产看。如下图,有Tile Info的MapService才有切片地图服务能力。



既然地图服务的URL一样,那怎么去区别使用呢?

使用MapService的哪种能力,要通过API去控制,要看程序用什么图层对象去承接MapService。

如果我用ArcGISMapImageLayer对象去承接,则使用的是动态地图服务的能力,如果使用的是ArcGISTiledLayer对象去承接,则使用的是切片地图服务的能力。

下面给出动态地图服务加载的代码和切片地图服务加载的代码。

<esri:Scene.OperationalLayers>
<esri:ArcGISMapImageLayer Source="http://services.arcgisonline.com/arcgis/rest/services/Demographics/USA_Population_by_Sex/MapServer"></esri:ArcGISMapImageLayer>
<esri:ArcGISTiledLayer Source="http://services.arcgisonline.com/arcgis/rest/services/Demographics/USA_Population_by_Sex/MapServer"></esri:ArcGISTiledLayer>
<esri:ArcGISSceneLayer Name="BuildingsLayer"
Source="http://scene.arcgis.com/arcgis/rest/services/Hosted/Buildings_Brest/SceneServer/layers/0"/>
</esri:Scene.OperationalLayers>


一个服务同时有动态地图服务能力和切片服务能力的MapService,使用ArcGISMapImageLayer和使用ArcGISTiledLayer加载的最终效果一样,但是加载时间长短区别很大。切片地图服务是提前把每个比例尺下的地图切割成小块图片,保存在服务器上。这样客户端在访问地图时,直接获取需要的小块图片拼接成整幅地图,而不是由服务器动态创建出一幅图片再送到客户端,极大程度提高了访问速度。

要素服务

要素服务一般被用作要素在线编辑。服务的URL与MapServer的URL略有不同。示例URL:
http://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/FeatureServer
要素服务的末尾不是MapServer,而是FeatureServer,并且在要素服务使用的过程中,往往是使用FeatureServer的具体图层。下面的代码展示了如何在地图中加载要素服务,至于要素服务怎么编辑,放到后面的内容中去探索。

Uri serviceUri = new Uri( "http://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/FeatureServer/0");
ServiceFeatureTable myFeatureTable =new ServiceFeatureTable(serviceUri);
myFeatureTable.FeatureRequestMode= FeatureRequestMode.OnInteractionNoCache;
FeatureLayer myFeatureLayer =newFeatureLayer(myFeatureTable);
myMap.OperationalLayers.Add(myFeatureLayer);


影像服务

影像服务这里不做过多介绍,这里给出一个影像服务的示例URL,并给出服务加载代码。
http://sampleserver6.arcgisonline.com/arcgis/rest/services/CharlotteLAS/ImageServer
ImageServiceRaster serviceRaster = new ImageServiceRaster(new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/CharlotteLAS/ImageServer"));
serviceRaster.Loaded += (s, e) =>
{
ArcGISImageServiceInfo serviceInfo = serviceRaster.ServiceInfo;
IReadOnlyList<RenderingRuleInfo> renderingRuleInfos = serviceInfo.RenderingRuleInfos;
RenderingRule renderingRule = new RenderingRule(renderingRuleInfos[3]);
serviceRaster.RenderingRule = renderingRule;
RasterLayer layer = new RasterLayer(serviceRaster);
};
serviceRaster.LoadAsync();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐