private static void LogWorkspaceProperties( [NotNull] IWorkspaceProperties props, params esriWorkspacePropertyType[] propertyTypes) { var watch = new Stopwatch(); foreach (esriWorkspacePropertyType propertyType in propertyTypes) { watch.Reset(); watch.Start(); IWorkspaceProperty property = props.Property[ esriWorkspacePropertyGroupType.esriWorkspacePropertyGroup, (int)propertyType]; watch.Stop(); if (property.IsSupported) { Console.WriteLine(@"{0}: {1} ({2:N6} ms)", propertyType, property.PropertyValue, watch.ElapsedTicks / (double)TimeSpan.TicksPerMillisecond); } else { Console.WriteLine(@"{0}: {1} [not supported] ({2:N6} ms)", propertyType, property.PropertyValue, watch.ElapsedTicks / (double)TimeSpan.TicksPerMillisecond); } } }
/// <summary> // 创建要素数据集 /// </summary> /// <param name="workspace"></param> /// <param name="code"></param> /// <param name="datasetName"></param> /// <returns></returns> public IFeatureDataset CreateFeatureClass(IWorkspace workspace, int code, string datasetName) { IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace; //创建一个要素集创建一个投影 ISpatialReferenceFactory spatialRefFactory = new SpatialReferenceEnvironmentClass(); ISpatialReference spatialReference = spatialRefFactory.CreateProjectedCoordinateSystem(code); //确定是否支持高精度存储空间 Boolean supportsHighPrecision = false; IWorkspaceProperties workspaceProperties = (IWorkspaceProperties)workspace; IWorkspaceProperty workspaceProperty = workspaceProperties.get_Property (esriWorkspacePropertyGroupType.esriWorkspacePropertyGroup, (int)esriWorkspacePropertyType.esriWorkspacePropSupportsHighPrecisionStorage); if (workspaceProperty.IsSupported) { supportsHighPrecision = Convert.ToBoolean(workspaceProperty.PropertyValue); } //设置投影精度 IControlPrecision2 controlPrecision = (IControlPrecision2)spatialReference; controlPrecision.IsHighPrecision = supportsHighPrecision; //设置容差 ISpatialReferenceResolution spatialRefResolution = (ISpatialReferenceResolution)spatialReference; spatialRefResolution.ConstructFromHorizon(); spatialRefResolution.SetDefaultXYResolution(); ISpatialReferenceTolerance spatialRefTolerance = (ISpatialReferenceTolerance)spatialReference; spatialRefTolerance.SetDefaultXYTolerance(); //创建要素集 IFeatureDataset featureDataset = featureWorkspace.CreateFeatureDataset(datasetName, spatialReference); return(featureDataset); }
public static bool IsConnectedToGeodatabase(IWorkspace iworkspace_0) { IWorkspaceProperties properties = (IWorkspaceProperties)iworkspace_0; return (Convert.ToBoolean( properties.get_Property(esriWorkspacePropertyGroupType.esriWorkspacePropertyGroup, 7).PropertyValue)); }