ArcGIS 10.0 ArcGIS 9.3.1数据生成实验--个人地理数据库
前段时间有个同事需要用到arcgis 工具将生成的分析数据转出为arcgis的格式存储到个人地理数据库中。但是在数据生成过程中,发现数据加载到arcmap放大到一定比例尺后数据就消失了,给我的第一个感觉,问题应该出现在坐标系统、容差设置等出了问题。于是我在自己的电脑上也实验了一下,发现无论怎么设置,都会有这个问题,即数据放大后就消失不显示。
但是如果新建一个个人地理数据库,再把生成的数据导入到新建的数据库中再放大显示就没有问题。所以很奇怪,直到今天的测试,才发现这有可能是10.0的一个bug,或者哪里没有设置好,看到的朋友如果直到的话,希望联系本人或者下面直接留言,望不吝赐教。
简单起见,数据都不设置坐标系统,仅设置地图数据框的显示单位
导出的要素数据
再放大也是毫无压力的
下面是测试代码
1 using System; 2 using System.Collections.Generic; 3 using System.Text; 4 using ESRI.ArcGIS.esriSystem; 5 using ESRI.ArcGIS.Geodatabase; 6 using ESRI.ArcGIS.Geometry; 7 using ESRI.ArcGIS.DataSourcesGDB; 8 9 namespace createmdbandinsertfc 10 { 11 class Program 12 { 13 private static LicenseInitializer m_AOLicenseInitializer = new createmdbandinsertfc.LicenseInitializer(); 14 15 [STAThread()] 16 static void Main(string[] args) 17 { 18 //ESRI License Initializer generated code. 19 m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeArcInfo }, 20 new esriLicenseExtensionCode[] { }); 21 CretePGDB(); 22 //ESRI License Initializer generated code. 23 //Do not make any call to ArcObjects after ShutDownApplication() 24 m_AOLicenseInitializer.ShutdownApplication(); 25 } 26 27 private static void CretePGDB() 28 { 29 Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.AccessWorkspaceFactory"); 30 IWorkspaceFactory2 workspaceFactory = (IWorkspaceFactory2)Activator.CreateInstance(factoryType); 31 IWorkspaceName workspaceName = workspaceFactory.Create(@"c:\", "Sample.mdb", null, 0); 32 33 //// Cast the workspace name object to the IName interface and open the workspace. 34 IName name = (IName)workspaceName; 35 IWorkspace workspace = (IWorkspace)name.Open(); 36 37 //直接打开 38 //IWorkspaceFactory pwf = new AccessWorkspaceFactory(); 39 //IWorkspace workspace = pwf.OpenFromFile(@"c:\Sample.mdb", 0); 40 //IFeatureWorkspace pFW = workspace as IFeatureWorkspace; 41 //IFeatureDataset pFD = pFW.OpenFeatureDataset("DXT"); 42 43 ISpatialReferenceFactory3 spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); 44 ISpatialReference pSRF = new UnknownCoordinateSystemClass(); 45 ISpatialReferenceResolution pSRFResolu = (ISpatialReferenceResolution)pSRF; 46 pSRFResolu.ConstructFromHorizon(); 47 pSRF.SetZDomain(0, 1); 48 pSRF.SetMDomain(0, 1); 49 ISpatialReferenceTolerance pSRFtolerance = (ISpatialReferenceTolerance)pSRF; 50 pSRFtolerance.SetDefaultXYTolerance(); 51 pSRFtolerance.SetDefaultMTolerance(); 52 pSRFtolerance.SetDefaultZTolerance(); 53 IControlPrecision2 controlPrecision = pSRF as IControlPrecision2; 54 controlPrecision.IsHighPrecision = true; 55 56 //创建FeatureDataSet 57 IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace; 58 IFeatureDataset pDC = featureWorkspace.CreateFeatureDataset("DXT", pSRF); 59 //IFeatureClass pFC = CreateFeatureClass(pSRF, featureWorkspace); 60 IFeatureClass pFC = CreateFeatureClass(pSRF, pDC); 61 IGeodatabaseRelease pGDBR = workspace as IGeodatabaseRelease; 62 Console.WriteLine(pGDBR.MajorVersion + "." + pGDBR.MinorVersion + "-" + pGDBR.BugfixVersion); 63 pGDBR.Upgrade(); 64 Console.WriteLine(pGDBR.MajorVersion + "." + pGDBR.MinorVersion + "-" + pGDBR.BugfixVersion); 65 //IGeoDatasetSchemaEdit2 pGDSE = pDC as IGeoDatasetSchemaEdit2; 66 //pGDSE.AlterSpatialReference(pSRF); 67 //pGDSE.AlterResolution(1000,1, 1); 68 //根据创建的featuredataset创建featureclasss 69 //IFeatureClass pFC = CreateFeatureClass((pFD as IGeoDataset).SpatialReference, (pFD as IFeatureDataset)); 70 71 //直接打开已有的FC 72 //IFeatureClass pFC = pFW.OpenFeatureClass("节点"); 73 74 //IFeatureBuffer fb; 75 //IFeatureCursor insertCursor = pFC.Insert(true); 76 //IPoint point; 77 //for (int i = 0; i < 100; i++) 78 //{ 79 // fb = pFC.CreateFeatureBuffer(); 80 // point = new PointClass(); 81 // point.PutCoords(40000.0+i*1000, 4000.0-i*200); 82 // fb.Shape = point; 83 // insertCursor.InsertFeature(fb); 84 //} 85 IWorkspace pws = ((IDataset)pFC).Workspace; 86 IWorkspaceEdit pwe = pws as IWorkspaceEdit; 87 bool startEdit = pwe.IsBeingEdited(); 88 if (!startEdit) 89 { 90 pwe.StartEditing(false); 91 } 92 pwe.StartEditOperation(); 93 94 //是否需要清除原来数据 95 96 97 IFeature pFeature; 98 for (double i = 0; i < 180; i+=0.5) 99 { 100 pFeature = pFC.CreateFeature(); 101 IPoint point = new PointClass(); 102 point.PutCoords(i ,Math.Sin(90*i*Math.PI/180.0)); 103 pFeature.Shape = point; 104 pFeature.Store(); 105 pFeature = null; 106 } 107 108 pwe.StopEditOperation(); 109 startEdit = pwe.IsBeingEdited(); 110 if (startEdit) 111 { 112 pwe.StopEditing(true); 113 } 114 115 } 116 117 //private static IFeatureClass CreateFeatureClass(ISpatialReference pSRF, IFeatureWorkspace pDC) 118 private static IFeatureClass CreateFeatureClass(ISpatialReference pSRF, IFeatureDataset pDC) 119 { 120 // Locations are all relative to the location of the reference lines. 121 // For geodatabase, signs feature class is at the same location and the streets table 122 // is at the level of the containing feature dataset. 123 // For shapefile, both are at the same location as the reference lines. 124 // start with the initial set of required fields for a feature class 125 126 IFeatureClassDescription fcDescription = new FeatureClassDescriptionClass(); 127 IObjectClassDescription ocDescription = fcDescription as IObjectClassDescription; 128 IFieldsEdit outFields = ocDescription.RequiredFields as IFieldsEdit; 129 130 // make the shape field to be of type polyline with the same spatial reference as the reference lines 131 132 IField shapeField = outFields.get_Field(outFields.FindField(fcDescription.ShapeFieldName)); 133 IGeometryDefEdit geomDefEdit = shapeField.GeometryDef as IGeometryDefEdit; 134 geomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint; 135 // Set the grid count to 1 and the grid size to 0 to allow ArcGIS to 136 // determine a valid grid size. 137 geomDefEdit.GridCount_2 = 1; 138 geomDefEdit.set_GridSize(0, 0); 139 geomDefEdit.SpatialReference_2 = pSRF; 140 141 // add the other fields to the feature class 142 143 IFieldEdit field = new FieldClass(); 144 field.Name_2 = "ExitName"; 145 field.Type_2 = esriFieldType.esriFieldTypeString; 146 field.Length_2 = 10; 147 outFields.AddField(field); 148 149 field = new FieldClass(); 150 field.Name_2 = "X"; 151 field.Type_2 = esriFieldType.esriFieldTypeString; 152 field.Length_2 = 75; 153 outFields.AddField(field); 154 155 field = new FieldClass(); 156 field.Name_2 = "Y"; 157 field.Type_2 = esriFieldType.esriFieldTypeString; 158 field.Length_2 = 75; 159 outFields.AddField(field); 160 161 field = new FieldClass(); 162 field.Name_2 = "Branch" + "Lng"; 163 field.Type_2 = esriFieldType.esriFieldTypeString; 164 field.Length_2 = 2; 165 outFields.AddField(field); 166 167 field = new FieldClass(); 168 field.Name_2 = "Toward"; 169 field.Type_2 = esriFieldType.esriFieldTypeString; 170 field.Length_2 = 75; 171 outFields.AddField(field); 172 173 field = new FieldClass(); 174 field.Name_2 = "Toward" + "Lng"; 175 field.Type_2 = esriFieldType.esriFieldTypeString; 176 field.Length_2 = 2; 177 outFields.AddField(field); 178 return pDC.CreateFeatureClass( 179 "节点", 180 outFields, 181 ocDescription.InstanceCLSID, 182 ocDescription.ClassExtensionCLSID, 183 esriFeatureType.esriFTSimple, 184 fcDescription.ShapeFieldName, 185 "" 186 ); 187 } 188 189 190 } 191 }
本机环境
Windows server 2008 r2
ArcGIS 10.0 sp5
代码分别又在下面两个环境进行了测试,仅修改授权过程部分代码。
测试环境【一】
Windows server 2003
ArcGIS 9.3.1
生成的数据可以正常放大显示,不会出现消失的现象
测试环境【二】
Windows 10
ArcGIS10.2
效果同10.0
没办法,直接打开MDB
比较也未有什么重要发现。
arcgis 931平台的PGDB版本2.3.0
arcgis 10.0和arcgis10.2的PGDB 3.0.0
难道真的是软件自身的bug吗?
转载于:https://www.cnblogs.com/5igis/p/5igis_11793.html