本文整理汇总了C#中SpatialFilterClass.set_OutputSpatialReference方法的典型用法代码示例。如果您正苦于以下问题:C# SpatialFilterClass.set_OutputSpatialReference方法的具体用法?C# SpatialFilterClass.set_OutputSpatialReference怎么用?C# SpatialFilterClass.set_OutputSpatialReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpatialFilterClass
的用法示例。
在下文中一共展示了SpatialFilterClass.set_OutputSpatialReference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Query
/// <summary>
/// Queries the specified layer id.
/// </summary>
/// <param name="layerId">The layer id.</param>
/// <param name="spatialFilter">The spatial filter.</param>
/// <param name="attributeFilter">The attribute filter.</param>
/// <param name="transformationId">The transformation id.</param>
/// <returns></returns>
public RecordSet Query(int layerId, IGeometry spatialFilter, string attributeFilter, string geometryFieldName, ExportOutputSpatialReference outputSr)
{
ISpatialFilter filter = new SpatialFilterClass();
RecordSet recordSet = null;
IQueryResultOptions resultOptions;
IMapTableDescription tableDesc;
IQueryResult result;
try
{
//set the filter properties
filter.Geometry = spatialFilter;
//todo
//the geometry field name comes in via the request, but could we look at layerinfo from the map server?
//the type of spatial reference systen should be passed in: i.e. geographic or projected
//already implemented method: GetFeatureClassShapeFieldName which does this
//create desired output spatial reference
if (outputSr != null)
{
Type t = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
System.Object obj = Activator.CreateInstance(t);
ISpatialReferenceFactory srFact = obj as ISpatialReferenceFactory;
ISpatialReference sr;
if (outputSr.CoordinateSystemType == "projected")
{
sr = srFact.CreateProjectedCoordinateSystem((int)outputSr.Wkid);
}
else sr = srFact.CreateGeographicCoordinateSystem((int)outputSr.Wkid);
filter.GeometryField = geometryFieldName;
filter.set_OutputSpatialReference(geometryFieldName, sr);
}
filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
if (!String.IsNullOrEmpty(attributeFilter))
filter.WhereClause = attributeFilter;
//set the result options
resultOptions = new QueryResultOptionsClass();
resultOptions.Format = esriQueryResultFormat.esriQueryResultRecordSetAsObject;
//apply transformation if required
if (outputSr != null)
{
if (outputSr.TransformationId != null)
{
Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
ISpatialReferenceFactory3 srFactory = (ISpatialReferenceFactory3)Activator.CreateInstance(factoryType);
IGeoTransformation gt;
gt = srFactory.CreateGeoTransformation((int)outputSr.TransformationId) as IGeoTransformation;
resultOptions.GeoTransformation = gt;
}
}
tableDesc = GetTableDesc(_server, layerId);
result = _server.QueryData(_server.DefaultMapName, tableDesc, filter, resultOptions);
//IlayerDescription3 lyrDesc = GetLayerDesc(_server, layerId);
//result = _server.QueryFeatureData2(_server.DefaultMapName, lyrDesc, filter, resultOptions);
recordSet = result.Object as RecordSet;
return recordSet;
}
catch (Exception ex)
{
throw ex;
}
finally
{
filter = null;
resultOptions = null;
tableDesc = null;
result = null;
}
}