ArcGIS Engine代码共享-工作空间(workspace)对象操作
代码:
public class WorkspaceHelper
{
public static string GISConnectionString;
public static IWorkspace GetAccessWorkspace(string sFilePath)
{
if (!File.Exists(sFilePath))
{
return null;
}
try
{
IWorkspaceFactory factory = new AccessWorkspaceFactoryClass();
return factory.OpenFromFile(sFilePath, );
}
catch
{
return null;
}
}
public static IWorkspace GetSDEWorkspace(string sServerName, string sInstancePort, string sUserName, string sPassword, string sVersionName)
{
IPropertySet set = new PropertySetClass();
set.SetProperty("Server", sServerName);
set.SetProperty("Instance", sInstancePort);
set.SetProperty("User", sUserName);
set.SetProperty("password", sPassword);
set.SetProperty("version", sVersionName);
SdeWorkspaceFactoryClass class2 = new SdeWorkspaceFactoryClass();
try
{
return class2.Open(set, );
}
catch (Exception ex)
{
return null;
}
}
public static IWorkspace GetFGDBWorkspace(string sFilePath)
{
if (!System.IO.Directory.Exists(sFilePath))
{
return null;
}
try
{
IWorkspaceFactory factory = new FileGDBWorkspaceFactoryClass();
return factory.OpenFromFile(sFilePath,);
}
catch
{
return null;
}
}
public static IWorkspace GetShapefileWorkspace(string sFilePath)
{
if (!File.Exists(sFilePath))
{
return null;
}
try
{
IWorkspaceFactory factory = new ShapefileWorkspaceFactoryClass();
sFilePath = System.IO.Path.GetDirectoryName(sFilePath);
return factory.OpenFromFile(sFilePath, );
}
catch
{
return null;
}
}
public static string PGDBDataConnectionString(string sPath)
{
return ("Provider=ESRI.GeoDB.OLEDB.1;Data Source=" + sPath + ";Extended Properties=workspacetype=esriDataSourcesGDB.AccessWorkspaceFactory.1;Geometry=WKB");
}
public static string SDEDataConnectionString(string sServerName, string sDataSource, string sUserName, string sPW)
{
return ("Provider=ESRI.GeoDB.OLEDB.1;Location=" + sServerName + ";Data Source=" + sDataSource + "; User Id=" + sUserName + ";Password=" + sPW + "; Extended Properties=WorkspaceType= esriDataSourcesGDB.SDEWorkspaceFactory.1;Geometry=WKB|OBJECT;Instance=5151;Version=SDE.DEFAULT");
}
public static string ShapefileDataConnectionString(string sPath)
{
sPath = System.IO.Path.GetDirectoryName(sPath);
return ("Provider=ESRI.GeoDB.OLEDB.1;Data Source=" + sPath + ";Extended Properties=WorkspaceType=esriDataSourcesFile.ShapefileWorkspaceFactory.1;Geometry=WKB|OBJECT");
}
public static bool HighPrecision(IWorkspace pWorkspace)
{
IGeodatabaseRelease geoVersion = pWorkspace as IGeodatabaseRelease;
if (geoVersion == null) return false;
if (geoVersion.MajorVersion ==
&& geoVersion.MinorVersion == )
{
return true;
}
return false;
}
public static List<String> QueryFeatureClassName(IWorkspace pWorkspace)
{
return QueryFeatureClassName(pWorkspace, false, false);
}
public static List<String> QueryFeatureClassName(IWorkspace pWorkspace, bool pUpperCase)
{
return QueryFeatureClassName(pWorkspace, pUpperCase, false);
}
public static List<String> QueryFeatureClassName(IWorkspace pWorkspace, bool pUpperCase, bool pEscapeMetaTable)
{
try
{
String ownerName = "";
if (pWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
{
ownerName = pWorkspace.ConnectionProperties.GetProperty("user").ToString();
ownerName = ownerName.ToUpper();
}
List<String> sc = new List<String>();
IEnumDatasetName edn = pWorkspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
IDatasetName dn = edn.Next();
while (dn != null)
{
string dsName = dn.Name.ToUpper();
if (ownerName.Equals(LayerHelper.GetClassOwnerName(dsName)))
{
#region 添加数据集下面的FeatureClass
IEnumDatasetName fdn = dn.SubsetNames; dn = fdn.Next();
while (dn != null)
{
dsName = dn.Name.ToUpper();
bool isTopology = dn is ITopologyName;
if (!isTopology)
{
string shortName = LayerHelper.GetClassShortName(dsName);
if (pUpperCase)
{
shortName = shortName.ToUpper();
}
if (pEscapeMetaTable)
{ }
else
{
sc.Add(shortName);
}
}
dn = fdn.Next();
}
#endregion
}
dn = edn.Next();
}
#region 获取直接的FeatureClass
edn = pWorkspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
dn = edn.Next();
while (dn != null)
{
string dsName = dn.Name.ToUpper();
if (ownerName.Equals(LayerHelper.GetClassOwnerName(dsName)))
{
string shortName = LayerHelper.GetClassShortName(dsName);
if (pUpperCase)
{
shortName = shortName.ToUpper();
}
if (pEscapeMetaTable)
{ }
else
{
sc.Add(shortName);
}
}
dn = edn.Next();
}
#endregion
return sc;
}
catch (Exception ex) { return null; }
}
public static List<IConfigurationKeyword> GetConfigurationKeywordList(IWorkspace pWS)
{
List<IConfigurationKeyword> pList = new List<IConfigurationKeyword>();
IWorkspaceConfiguration pWConfig = pWS as IWorkspaceConfiguration;
IEnumConfigurationKeyword pEnumConfig = pWConfig.ConfigurationKeywords;
IConfigurationKeyword pConfig = pEnumConfig.Next();
while (pConfig != null)
{
pList.Add(pConfig);
pConfig = pEnumConfig.Next();
}
return pList;
}
public static List<IConfigurationParameter> GetConfigurationParameterList(IConfigurationKeyword pConfig)
{
List<IConfigurationParameter> pList = new List<IConfigurationParameter>();
IEnumConfigurationParameter pEnumCP = pConfig.ConfigurationParameters;
IConfigurationParameter pCP = pEnumCP.Next();
while (pCP != null)
{
pList.Add(pCP);
pCP = pEnumCP.Next();
}
return pList;
}
}
ArcGIS Engine代码共享-工作空间(workspace)对象操作的更多相关文章
- vs.net调试ArcGIS Engine代码查看变量时,提示“要检查本机对象,请启用本机代码调试。” 的解决方法
用vs2017 调试 查看ArcGIS Engine 的变量时 会提示如下图所示的错误: 解决方法: 工具->选项->调试->常规->使用托管的兼容模式 如下图所示: 2.设置 ...
- ArcGIS Engine开发之旅09--几何对象和空间参考
原文:ArcGIS Engine开发之旅09--几何对象和空间参考 1.Geometry Geometry 是 GIS 中使用最为广泛的对象集之一,用户在创建.删除.编辑和进行地理分析的时候,就是处 ...
- Arcgis engine 指定图层对要素进行创建、删除等操作
Arcgis engine 指定图层创建点要素 在指定的图层上创建一个点要素,点要素的位置是通过X,Y坐标指定的,下面是具体的注释 .其中 和IFeatureClassWrite接口有关的代码不要好像 ...
- ArcGIS Engine开发之旅08--和查询相关的对象和接口
原文:ArcGIS Engine开发之旅08--和查询相关的对象和接口 查询在GIS领域应该是一个很频繁的操作,在GIS中除了具有属性查询(和其他关系型数据库的查询类似),还提供了空间查询.在介绍查询 ...
- ArcGIS Engine Style文件操作
对于一个GISer来说,地图,符号这些都应该有着比别人更深刻的理解和认识,作为平台软件都会提供一套自己的符号库,符号库里面根据类别和种类进行区分,因为点,线,面的自然存在和固有属性是不肯能让你用面状符 ...
- J2EE(java)后台调用ArcGIS Engine(AE)的部署和代码
arcgis的BS开发解决方案一直是个坑,主推的地图服务查询速度慢,需要异步,功能少.相对来说主要用于CS的AE功能更强大全面,只是部署有点复杂 本文软件环境: win7 sp1 64位 MyEcli ...
- 危险代码:如何使用Unsafe操作内存中的Java类和对象
危险代码:如何使用Unsafe操作内存中的Java类和对象—Part1 危险代码:如何使用Unsafe操作内存中的Java类和对象—Part2 危险代码:如何使用Unsafe操作内存中的Java类和对 ...
- ArcGIS Engine开发之地图基本操作(4)
ArcGIS Engine开发中数据库的加载 1.加载个人地理数据库数据 个人地理数据库(Personal Geodatabase)使用Miscrosoft Access文件(*.mdb)进行空间数据 ...
- ArcGIS Engine开发之旅04---ARCGIS接口详细说明
原文:ArcGIS Engine开发之旅04---ARCGIS接口详细说明 ArcGIS接口详细说明... 1 1. IField接口(esriGeoDatabase)... 2 2. ...
随机推荐
- ios 屏幕概况
转:http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions
- 21. Clone Graph
Clone Graph Clone an undirected graph. Each node in the graph contains a label and a list of its nei ...
- 动态规划 - 最长递增子序列(LIS)
最长递增子序列是动态规划中经典的问题,详细如下: 在一个已知的序列{a1,a2,...,an}中,取出若干数组组成新的序列{ai1,ai2,...,aim},其中下标i1,i2,...,im保持递增, ...
- 手把手教你编写一个具有基本功能的shell(已开源)
刚接触Linux时,对shell总有种神秘感:在对shell的工作原理有所了解之后,便尝试着动手写一个shell.下面是一个从最简单的情况开始,一步步完成一个模拟的shell(我命名之为wshell) ...
- HTTP请求之:PHP函数header常用功能
1.页面重定向 当浏览器接受到头信息中的 Location: http://xxxx 后,就会自动跳转到 http://xxxx 指向的URL地址,这点有点类似用 js 写跳转.但是这个跳转只有浏 ...
- CSS布局--浮动与清除
浮动和清除 浮动和清除是页面布局的重要属性.浮动的意思是指将元素从常规的文档流中取出来. 当你浮动一个元素的时候,浮动的元素会被浏览器尽量的往上放,能放多高就放多高,一直到某个元素的边界为止. 浮动元 ...
- python sort和sorted的区别以及使用方法
iteralbe指的是能够一次返回它的一个成员的对象.iterable主要包括3类: 第一类是所有的序列类型,比如list(列表).str(字符串).tuple(元组). 第二类是一些非序列类型,比如 ...
- Couldn't resolve Mac Server "mymac"
vs2015创建一个iphone app ,Couldn't resolve Mac Server “mymac” 伤.下班走人
- 64位Win7下运行ASP+Access网站的方法
64位Win7下运行ASP+Access网站的方法 近日系统升级为WIN7 64位之后,突然发现原本运行正常的ASP+ACCESS网站无法正常连接数据库. 网上搜索多次,终于解决了问题,总结了几条经验 ...
- GridView多列排序
public class WebGridView:GridView { 属性#region 属性 /**//// <summary> /// 是否启用或者禁止多列排序 /// </s ...