// 判断点pt落在哪个多边形内
ESRI.ArcGIS.ADF.Identity id = new ESRI.ArcGIS.ADF.Identity();
id.UserName = "Administrator" ;
id.Password = "123456";
id.Domain = "gis2_trq";
string domainstr = "10.150.38.34";
ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsconn = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(domainstr, id);
agsconn.Connect();
if (!agsconn.IsConnected)
{
agsconn.Dispose();
return "";
}
ESRI.ArcGIS.Server.IServerObjectManager som = agsconn.ServerObjectManager;
string servertype = "MapServer";
string serverobjectname2 = "MapRs";
ESRI.ArcGIS.Server.IServerContext sc2 = som.CreateServerContext(serverobjectname2, servertype);
IMapServer pMapServer2 = sc2.ServerObject as IMapServer;
IMapServerObjects pMapServerObjs2 = pMapServer2 as IMapServerObjects;
IMap pMap2 = pMapServerObjs2.get_Map(pMapServer2.DefaultMapName);
ICompositeLayer pCLayer2 = pMap2.get_Layer(3) as ICompositeLayer;
IFeatureLayer pFLayer2 = pCLayer2.get_Layer(2) as IFeatureLayer;
IFeatureClass pFeatureClass2 = pFLayer2.FeatureClass;
ESRI.ArcGIS.Geodatabase.IQueryFilter qFilter2 = sc.CreateObject("esriGeodatabase.QueryFilter") as ESRI.ArcGIS.Geodatabase.QueryFilter;
qFilter2.WhereClause = null;
IFeatureCursor fCursor2 = pFeatureClass2.Search(qFilter2, true);
IFeature feature2;
string CountryName=String.Empty;
ESRI.ArcGIS.Geometry.IPolygon polygon = null;
while ((feature2 = fCursor2.NextFeature()) != null)
{
polygon = feature2.Shape as ESRI.ArcGIS.Geometry.IPolygon;
ESRI.ArcGIS.Geometry.IRelationalOperator pRelOperator = polygon as ESRI.ArcGIS.Geometry.IRelationalOperator;
if (pRelOperator.Contains(pt))
{
CountryName = feature2.get_Value(1).ToString();
}
}
//获得的CountryName 即为点pt所在的多边形的name属性