ArcEngine服务数据加载

/// <summary>
///     地图服务
/// </summary>
public static class MapServer
{/// <summary>///     读取WMTS(Web Map Tile Service)服务数据.///     缓存技术标准。服务器端把地图切割为一定不同级别大小的瓦片,降低了服务器端的载荷///     示例:http://222.240.228.72:8060/arcgis/rest/services/yingxiang2016/MapServer/WMTS/1.0.0/WMTSCapabilities.xml/// </summary>/// <param name="url"></param>/// <param name="layerName"></param>/// <returns></returns>public static ILayer ReadWmtsServer(string url, string layerName){IPropertySet propertySet = new PropertySetClass();propertySet.SetProperty("url", url);//TODO 属性名称是layerName?if (layerName != "")propertySet.SetProperty("layerName", layerName);IWMTSConnectionFactory wmtsConnectionfactory = new WMTSConnectionFactory();var con = wmtsConnectionfactory.Open(propertySet, 0, null);IWMTSLayer wmtsLayer = new WMTSLayer();var n = con.FullName;wmtsLayer.Connect(n);var layer = wmtsLayer as ILayer;layer.Cached = true;layer.Name = layerName;return layer;}/// <summary>///     读取WMS(WebMapService)服务数据/// </summary>/// <param name="url"></param>/// <param name="layerName"></param>/// <returns></returns>public static ILayer ReadWmsServer(string url, string layerName){IPropertySet propertyset = new PropertySetClass();propertyset.SetProperty("url", url);IWMSConnectionFactory pWmsFac = new WMSConnectionFactory();var pWmsC = pWmsFac.Open(propertyset, 0, null);var pWmsConnectionName = pWmsC.FullName as IWMSConnectionName;//下面的也可以//IWMSConnectionName pWmsConnectionName = new WMSConnectionNameClass();//pWmsConnectionName.ConnectionProperties = pPropertyset;ILayerFactory pLayerFactory = new EngineWMSMapLayerFactoryClass();ILayer target = null;if (pLayerFactory.get_CanCreate(pWmsConnectionName)){var pEnumLayer = pLayerFactory.Create(pWmsConnectionName);pEnumLayer.Reset();var pLayer = pEnumLayer.Next();while (pLayer != null){//IWMSMapLayer pWmsMapLayer = pLayer as IWMSMapLayer;//IWMSGroupLayer pWmsGroupLayer = pWmsMapLayer as IWMSGroupLayer;//IGroupLayer pGroupLayer = new GroupLayerClass();//pGroupLayer.Add(pLayer);if (pLayer is IWMSMapLayer && pLayer.Name == layerName){target = pLayer;break;}pLayer = pEnumLayer.Next();}Marshal.ReleaseComObject(pEnumLayer);}return target;}/// <summary>///     读取WCS(Web Coverage Service)服务数据(WCS对应基于栅格数据的功能,与WMS基于矢量数据的特点相对应)/// </summary>/// <param name="url"></param>/// <param name="layerName"></param>/// <returns></returns>public static ILayer ReadWcsServer(string url, string layerName){IPropertySet propertyset = new PropertySetClass();propertyset.SetProperty("url", url);IWCSConnectionFactory wcsConnectionFactory = new WCSConnectionFactory();var wcsConnection = wcsConnectionFactory.Open(propertyset, 0, null);var wcsConnectionName = wcsConnection.FullName as IWCSConnectionName;//下面的也可以//IWMSConnectionName pWmsConnectionName = new WMSConnectionNameClass();//pWmsConnectionName.ConnectionProperties = pPropertyset;WCSLayerFactory wCSLayerFactory = new WCSLayerFactoryClass();ILayer target = null;if (wCSLayerFactory.get_CanCreate(wcsConnectionName)){var pEnumLayer = wCSLayerFactory.Create(wcsConnectionName);pEnumLayer.Reset();var layer = pEnumLayer.Next();while (layer != null){if (layer is IWCSLayer && layer.Name == layerName) {target= layer;break;}layer = pEnumLayer.Next();}}return target;}/// <summary>///     获取ArcGISServer服务图层/// </summary>/// <param name="hostOrUrl"></param>/// <param name="serviceName">服务名称</param>/// <param name="isLAN">是否直连</param>/// <param name="layerName">图层名称</param>/// <returns></returns>public static ILayer ReadMapServer(string hostOrUrl, string serviceName, bool isLAN, string layerName){ILayer target = null;IMapServer mapServer;//获得服务对象名称var pServerObjectName = GetMapServer(hostOrUrl, serviceName, isLAN); //获取地图var pName = (IName)pServerObjectName;//访问地图服务var pServerObject = (IAGSServerObject)pName.Open();var pMapServer = (IMapServer)pServerObject;mapServer = pMapServer; //获取地图服务对象var pMapServerLayer = new MapServerLayer() as IMapServerLayer;//连接地图服务pMapServerLayer.ServerConnect(pServerObjectName, pMapServer.DefaultMapName);//添加数据图层target = pMapServerLayer as ILayer;target.Cached = true;if (!string.IsNullOrEmpty(layerName)) target.Name = layerName;return target;}/// <summary>///     读取image server/// </summary>/// <param name="url"></param>/// <param name="layerName"></param>/// <returns></returns>public static ILayer ReadImageServer(string url, string layerName){IImageServerLayer imageServerLayer = new ImageServerLayerClass();imageServerLayer.Initialize(url);var raster = imageServerLayer.Raster;IRasterLayer rasterLayer = new RasterLayerClass();rasterLayer.CreateFromRaster(raster);rasterLayer.Name = layerName;return rasterLayer;}/// <summary>///     获取ArcGisServer地图服务标识,连接服务器/// </summary>/// <param name="pHostOrUrl"></param>/// 服务器主机URL/// <param name="pServiceName"></param>/// 服务名称/// <param name="pIsLAN"></param>/// 主机是否是在局域网或者是互联网/// <returns></returns>private static IAGSServerObjectName GetMapServer(string pHostOrUrl, string pServiceName, bool pIsLAN){try{//设置连接属性IPropertySet pPropertySet = new PropertySet();if (pIsLAN)pPropertySet.SetProperty("machine", pHostOrUrl);elsepPropertySet.SetProperty("url", pHostOrUrl);//打开连接IAGSServerConnectionFactory pFactory = new AGSServerConnectionFactory();//创建服务器连接工作空间var pConnection = pFactory.Open(pPropertySet, 0);//打开获取服务器var pServerObjectNames = pConnection.ServerObjectNames;//获取服务器上所有服务的标识属性,即服务标识集合pServerObjectNames.Reset();//使指针指向服务开头var ServerObjectName = pServerObjectNames.Next();//获取服务标识while (ServerObjectName != null){if (ServerObjectName.Name.ToLower() == pServiceName.ToLower() &&ServerObjectName.Type == "MapServer")//判断获取所需服务break;ServerObjectName = pServerObjectNames.Next();}//返回对象return ServerObjectName; //返回服务标识}catch{return null;}}
}

ArcEngine服务数据加载相关推荐

  1. Vue3.0+Cesium+Tomcat服务下倾斜摄影数据加载详细过程

    Vue3.0+Cesium+Tomcat服务下倾斜摄影数据加载 1.Vue-cli 3.0 + cesium 构建 参考资料地址Vue-cli 3.0 + cesium 构建 注意,因为文档中设置默认 ...

  2. hive 导入hdfs数据_将数据加载或导入运行在基于HDFS的数据湖之上的Hive表中的另一种方法。

    hive 导入hdfs数据 Preceding pen down the article, might want to stretch out appreciation to all the well ...

  3. 《利用Python进行数据分析·第2版》第6章 数据加载、存储与文件格式

    第1章 准备工作 第2章 Python语法基础,IPython和Jupyter 第3章 Python的数据结构.函数和文件 第4章 NumPy基础:数组和矢量计算 第5章 pandas入门 第6章 数 ...

  4. azure云数据库_从Azure Databricks将数据加载到Azure SQL数据库

    azure云数据库 In this article, we will learn how we can load data into Azure SQL Database from Azure Dat ...

  5. bootstrap table 动态列数据加载(一)

    bootstrap table 动态列数据加载(一) 我想把所有的收费项目作为表头,不固定死收费项目,数据库中有啥就显示啥. 动态数据加载时,不能用bean的嵌套,源码中加载表头和数据是分开的,第几列 ...

  6. 【数据分析项目实战】商铺数据加载及存储

    ''' [项目] 商铺数据加载及存储要求: 1.成功读取"商铺数据.csv"文件 2.解析数据,存成列表字典格式:[{'var1':value1,'var2':value2,'va ...

  7. loading数据加载的6种形式

    数据加载的几种形式及对应的交互设计 1.全屏加载 多出现在H5页面,例如微信的文章详情页.全屏加载的特点是数据一次性加载完成,内容加载完成之前界面都会停留在loading界面.进度条和有趣的动画设计, ...

  8. [转载]使用 Apache 的 POI 和 HSSF 将 Excel 电子表格数据加载到 DB2

    使用 Apache 的 POI 和 HSSF 将 Excel 电子表格数据加载到 DB2 在本文中,您将学习如何使用 Apache 的 POI 和 HSSF 构建能将 Microsoft Excel ...

  9. ignite mysql_apache ignite系列(三):数据处理(数据加载,数据并置,数据查询)

    ​使用ignite的一个常见思路就是将现有的关系型数据库中的数据导入到ignite中,然后直接使用ignite中的数据,相当于将ignite作为一个缓存服务,当然ignite的功能远不止于此,下面以将 ...

最新文章

  1. GitHub Draft Pull请求支持新的协作流程
  2. 某百度程序员中午面试一个阿里程序员,晚上去阿里面试,面试官竟是中午那个人!...
  3. python的特点和优点-【Python面试】 Python 的特点和优点是什么?
  4. 如何让类对象只在栈(堆)上分配空间?(转)
  5. 日照油库系统推荐_生产车间用什么地坪好?这款地面硬化系统使用一年后获车间主任点赞:太省心!| 项目回访...
  6. ES6箭头函数和模板字符串
  7. 新0-Day漏洞或将给Linux桌面发行版带来浩劫
  8. option columns.render 渲染列(1) 添加checkbox
  9. Nginx的TCP运行时健康检查
  10. 【OOAD】OOAD概述
  11. electron 的窗口设置最大化 最小化
  12. 【转】 TechED2010与我(三) —— 初识云计算
  13. 回斯坦福之后研究成果曝光,李飞飞团队用机器学习教机械臂做动作
  14. FPGA/数字IC秋招笔试面试003——FSM有限状态机、三段式状态机(2022届)
  15. 遗传算法 python 简书_基本遗传算法介绍
  16. 汇编语言学习:VM上安装Win98系统
  17. 泡泡龙游戏开发系列教程(一)
  18. 问卷调查的数据分析怎么做
  19. 爱代挂php源码,爱代挂外包,爱准挂外包,代挂系统218元秒搭建
  20. 午夜与element-ui邂逅

热门文章

  1. CoOS使用教程——事件标志
  2. OBS录制设置基本介绍(1)
  3. 数字IC设计/FPGA工程师秋招面经
  4. HTML+CSS+JS生日快乐网站模板(多页面功能版本+音乐)
  5. jQuery移动端日历考勤记录
  6. 动态规划学习:零钱兑换
  7. 《元宇宙》的真实面貌,看了之后就感觉应该是这样的!!
  8. Secret Data Cage防泄密软件
  9. MD5加盐加密工具类(可直接使用)
  10. 天天酷跑java_利用Java怎么实现一个天天酷跑游戏