当前位置: 首页>>代码示例>>C#>>正文


C# SpatialFilterClass.set_OutputSpatialReference方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:geoplex,项目名称:arcgis-exporter-extension,代码行数:90,代码来源:MapServer.cs


注:本文中的SpatialFilterClass.set_OutputSpatialReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。