网络分析之最短路径查询系列:
ArcGIS Server的最短路径开发系列(1)
ArcGIS Server的最短路径开发系列(2)
ArcGIS Server的最短路径开发系列(2)补充
关于点的查询代码我贴在下面了,里面的代码我可能有部分代码没有用,但我还是写上了,希望大家见谅,大体思想我建议大家先去看看 flyingis的博客,他的那个系列是相当好的,建议大家都是看一下!特别是查询的例子,我也是有一部分照他的来做的,希望大家能从中得到感觉!
public
PointN Query_Point_Txt(
string
Point_stirng)
{
AGSBase agsbase = new AGSBase();
CommonFunction Som_connection = new CommonFunction();
Som_connection.Som_Connection();
IEnumerable func_enum = null;
func_enum = CsMap.GetFunctionalities();
System.Data.DataTable mytable = null;
PointN txt_Point = new PointN();
foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality gisfunctionality in func_enum)
{
//gisresource = gisfunctionality.Resource;
//对特定的数据库图层进行查询
if (gisfunctionality.Resource.Name == "CsMap")
{
bool supported = false;
ESRI.ArcGIS.ADF.Web.DataSources.IGISResource gisresource = null;
gisresource = gisfunctionality.Resource;
supported = gisresource.SupportsFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality));
//如果支持
if (supported)
{
ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality qfunc;
qfunc = (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)gisresource.CreateFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);
string[] lids;
string[] lnames;
qfunc.GetQueryableLayers(null, out lids, out lnames);
//对查询进行过滤
#region
ESRI.ArcGIS.ADF.Web.SpatialFilter spatialfilter = new ESRI.ArcGIS.ADF.Web.SpatialFilter();
spatialfilter.ReturnADFGeometries = false;
spatialfilter.MaxRecords = 10;
spatialfilter.WhereClause = "NAME LIKE '" + Point_stirng + "'";
spatialfilter.Geometry = CsMap.GetFullExtent();
#endregion
mytable = qfunc.Query(null, lids[agsbase.mapid], spatialfilter);
}
}
}
DataRowCollection drs = mytable.Rows;
int shpind = -1;
for (int i = 0; i < mytable.Columns.Count; i++)
{
if (mytable.Columns[i].DataType == typeof(ESRI.ArcGIS.ADF.Web.Geometry.Geometry))
{
shpind = i;
break;
}
}
try
{
foreach (DataRow dr in drs)
{
ESRI.ArcGIS.ADF.Web.Geometry.Multipoint geom = (ESRI.ArcGIS.ADF.Web.Geometry.Multipoint)dr[shpind];
ESRI.ArcGIS.ADF.Web.Geometry.PointCollection pointcol = geom.Points;
txt_Point.X = pointcol[0].X;
txt_Point.Y = pointcol[0].Y;
}
}
catch (Exception q)
{
}
return txt_Point;
}
{
AGSBase agsbase = new AGSBase();
CommonFunction Som_connection = new CommonFunction();
Som_connection.Som_Connection();
IEnumerable func_enum = null;
func_enum = CsMap.GetFunctionalities();
System.Data.DataTable mytable = null;
PointN txt_Point = new PointN();
foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality gisfunctionality in func_enum)
{
//gisresource = gisfunctionality.Resource;
//对特定的数据库图层进行查询
if (gisfunctionality.Resource.Name == "CsMap")
{
bool supported = false;
ESRI.ArcGIS.ADF.Web.DataSources.IGISResource gisresource = null;
gisresource = gisfunctionality.Resource;
supported = gisresource.SupportsFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality));
//如果支持
if (supported)
{
ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality qfunc;
qfunc = (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)gisresource.CreateFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);
string[] lids;
string[] lnames;
qfunc.GetQueryableLayers(null, out lids, out lnames);
//对查询进行过滤
#region
ESRI.ArcGIS.ADF.Web.SpatialFilter spatialfilter = new ESRI.ArcGIS.ADF.Web.SpatialFilter();
spatialfilter.ReturnADFGeometries = false;
spatialfilter.MaxRecords = 10;
spatialfilter.WhereClause = "NAME LIKE '" + Point_stirng + "'";
spatialfilter.Geometry = CsMap.GetFullExtent();
#endregion
mytable = qfunc.Query(null, lids[agsbase.mapid], spatialfilter);
}
}
}
DataRowCollection drs = mytable.Rows;
int shpind = -1;
for (int i = 0; i < mytable.Columns.Count; i++)
{
if (mytable.Columns[i].DataType == typeof(ESRI.ArcGIS.ADF.Web.Geometry.Geometry))
{
shpind = i;
break;
}
}
try
{
foreach (DataRow dr in drs)
{
ESRI.ArcGIS.ADF.Web.Geometry.Multipoint geom = (ESRI.ArcGIS.ADF.Web.Geometry.Multipoint)dr[shpind];
ESRI.ArcGIS.ADF.Web.Geometry.PointCollection pointcol = geom.Points;
txt_Point.X = pointcol[0].X;
txt_Point.Y = pointcol[0].Y;
}
}
catch (Exception q)
{
}
return txt_Point;
}