当前位置:网站首页>ArcEngine service data loading
ArcEngine service data loading
2022-04-22 14:24:00 【ShirmyMao】
ArcEngine Service data loading
/// <summary>
/// Map service
/// </summary>
public static class MapServer
{
/// <summary>
/// Read WMTS(Web Map Tile Service) Service data .
/// Cache technology standard . The server cuts the map into tiles of different sizes , Reduce the load on the server side
/// Example :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 The property name is 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>
/// Read WMS(WebMapService) Service data
/// </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;
// The following can also
//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>
/// Read WCS(Web Coverage Service) Service data (WCS Corresponding to the function based on raster data , And WMS Based on the characteristics of vector data )
/// </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;
// The following can also
//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>
/// obtain ArcGISServer Service layer
/// </summary>
/// <param name="hostOrUrl"></param>
/// <param name="serviceName"> The service name </param>
/// <param name="isLAN"> Direct connection </param>
/// <param name="layerName"> Layer Name </param>
/// <returns></returns>
public static ILayer ReadMapServer(string hostOrUrl, string serviceName, bool isLAN, string layerName)
{
ILayer target = null;
IMapServer mapServer;
// Get the service object name
var pServerObjectName = GetMapServer(hostOrUrl, serviceName, isLAN); // Get maps
var pName = (IName)pServerObjectName;
// Access map services
var pServerObject = (IAGSServerObject)pName.Open();
var pMapServer = (IMapServer)pServerObject;
mapServer = pMapServer; // Get map service object
var pMapServerLayer = new MapServerLayer() as IMapServerLayer;
// Connect map service
pMapServerLayer.ServerConnect(pServerObjectName, pMapServer.DefaultMapName);
// Add data layer
target = pMapServerLayer as ILayer;
target.Cached = true;
if (!string.IsNullOrEmpty(layerName))
target.Name = layerName;
return target;
}
/// <summary>
/// Read 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>
/// obtain ArcGisServer Map service identification , Connect to server
/// </summary>
/// <param name="pHostOrUrl"></param>
/// Server host URL
/// <param name="pServiceName"></param>
/// The service name
/// <param name="pIsLAN"></param>
/// Whether the host is on the LAN or the Internet
/// <returns></returns>
private static IAGSServerObjectName GetMapServer(string pHostOrUrl, string pServiceName, bool pIsLAN)
{
try
{
// Set connection properties
IPropertySet pPropertySet = new PropertySet();
if (pIsLAN)
pPropertySet.SetProperty("machine", pHostOrUrl);
else
pPropertySet.SetProperty("url", pHostOrUrl);
// Open the connection
IAGSServerConnectionFactory pFactory = new AGSServerConnectionFactory();
// Create a server connection workspace
var pConnection = pFactory.Open(pPropertySet, 0);
// Open get server
var pServerObjectNames = pConnection.ServerObjectNames;
// Get the identification properties of all services on the server , That is, the set of service identifiers
pServerObjectNames.Reset();
// Make the pointer point to the beginning of the service
var ServerObjectName = pServerObjectNames.Next();
// Get service ID
while (ServerObjectName != null)
{
if (ServerObjectName.Name.ToLower() == pServiceName.ToLower() &&
ServerObjectName.Type == "MapServer")
// Judge to obtain the required services
break;
ServerObjectName = pServerObjectNames.Next();
}
// Returns the object
return ServerObjectName; // Return the service id
}
catch
{
return null;
}
}
}
版权声明
本文为[ShirmyMao]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221421351832.html
边栏推荐
- 深入理解读写锁ReentrantReadWriteLock和并发容器CopyOnWriteArrayList
- Binarytree练习二叉树序列化反序列化606、331、652、297
- 获取数组中每一项对象中的某个值的和(reduce的使用)
- error unable to access jarfile 解决方案
- TIANTI race - l2-002 linked list weight removal (25 points)
- interrupted()和isInterrupted()详述,百万数据分页查询的方法及其优化方式
- Blocking queue-
- 双指针||有序数组去重 排序链表移除元素 26、27、83
- 2. Flddler response shows the solution to the problem of garbled code
- 多线程初阶
猜你喜欢

BinaryTree练习 从前序与中序、中序与后序遍历序列构造二叉树||重构二叉树654、105、106

Kubernetes详解(六)——Pod对象部署和应用

awk命令
20道25K+Android工程师面试必问面试题,网易Android面试必问

Arcengine打印视图与布局视图原理解析

Spark code spark submit submit submit yarn cluster mode

多线程初阶
985硕艰难转行Android之路 加面经分享,美团安卓面试

Arcengine点,线,面,文本渲染

Completion of minmao e-commerce in 10 days - Implementation of user module (2nd day)
随机推荐
Pratique de l'arbre binaire itération récursive de l'arbre binaire 257, 100, 222, 101, 226, 437, 563, 617, 572, 543, | 687
Spark code spark submit submit submit yarn cluster mode
ArcEngine服务数据加载
天梯赛--L2-003 月饼 (25 分)
26 years old, 0 basic software testing still in time
MapReduce高级应用——全排序和二次排序
LeetCode刷题(04)
Thread pool--
Live classroom system platform software source code available for personal testing
Apache iotdb's UDF Source Analysis (1)
interrupted()和isInterrupted()详述,百万数据分页查询的方法及其优化方式
npm install --save 和 npm install --save-dev区别
ArcPy开发环境配置
天梯赛--L2-004 这是二叉搜索树吗? (25 分)(递归)
PIP command and online and offline installation method
ITopologicalOperator使用说明
Arcengine打印视图与布局视图原理解析
CorelDRAW插件-CPG插件开发-环境搭建-VS2017-TLB文件-CDR插件
深入剖析Lock与AQS
BinaryTree练习 从前序与中序、中序与后序遍历序列构造二叉树||重构二叉树654、105、106