using ArcGIS.Core.Data;
using ArcGIS.Core.Geometry;
using ArcGIS.Core.Hosting;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace ProCoreHost2
{
class Program
{
//[STAThread] must be present on the Application entry point
[STAThread]
static void Main(string[] args)
{
//授权
Host.Initialize();
DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.Oracle)
{
AuthenticationMode = AuthenticationMode.DBMS,
// ip: 端口/ 实例名称
Instance = "192.168.37.156:1521/orcl",
Database = "orcl",
User = "tys****t",
Password = "*****",
Version = "sde.DEFAULT"
};
using (Geodatabase geodatabase = new Geodatabase(connectionProperties))
using (FeatureClass schoolBoundaryFeatureClass = geodatabase.OpenDataset<FeatureClass>("ae2dltb"))
{
// 和 AE差不多
SpatialQueryFilter spatialQueryFilter = new SpatialQueryFilter();
spatialQueryFilter.SubFields ="OBJECTID,SHAPE";
System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
stopwatch.Start();
using (RowCursor indianPrairieCursor = schoolBoundaryFeatureClass.Search(spatialQueryFilter, true))
{
while (indianPrairieCursor.MoveNext())
{
using (Feature feature = (Feature)indianPrairieCursor.Current)
{
Geometry pGeo = feature.GetShape();
long id = feature.GetObjectID();
}
}
}
stopwatch.Stop();
Console.WriteLine(stopwatch.Elapsed.Minutes + "分" + stopwatch.Elapsed.Seconds + "秒");
}
System.Console.ReadLine();
}
}
}