/// <summary>
        /// 按照各种算子进行查询
        /// Query with the specified parameters
        /// </summary>
        /// <param name="mode"></param>
        public void Query(SpatialQueryMode mode)
        {
            try
            {
                // 获取地图中的选择集,并转换为记录集
                // Get the dataset in the map, and convert it to recordset.
                Selection[] selections = m_mapControl.Map.FindSelection(true);
                Selection   selection  = selections[0];
                Recordset   recordset  = selection.ToRecordset();

                // 设置查询参数
                // Set the query parameter.
                QueryParameter parameter = new QueryParameter();
                parameter.SpatialQueryObject = recordset;
                parameter.SpatialQueryMode   = mode;

                // 对指定查询的图层进行查询
                // Query the specified layer.
                Layer         layer   = this.GetLayerByCaption(m_queriedLayerName);
                DatasetVector dataset = layer.Dataset as DatasetVector;

                Recordset recordset2 = dataset.Query(parameter);
                layer.Selection.FromRecordset(recordset2);

                layer.Selection.Style.LineColor = Color.Red;
                layer.Selection.Style.LineWidth = 0.6;
                layer.Selection.SetStyleOptions(StyleOptions.FillSymbolID, true);
                layer.Selection.Style.FillSymbolID    = 1;
                layer.Selection.IsDefaultStyleEnabled = false;

                recordset2.Dispose();

                // 刷新地图
                // Refresh the map.
                m_mapControl.Map.Refresh();

                recordset.Dispose();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 2
0
 public void QueryByGeometry(string mapName, Geometry geometry, SpatialQueryMode spatialQueryMode, QueryParameterSet queryParameterSet, EventHandler<QueryEventArgs> completed, EventHandler<FailedEventArgs> failed)
 {
     QueryResource qr = BuildQueryResource(geometry, null, queryParameterSet, "SpatialQuery", spatialQueryMode.ToString(), null);
     QueryInternal(mapName, qr, completed, failed);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 在指定的地图上,查询与指定的几何对象符合某种空间关系和查询条件的几何对象。
 /// </summary>
 /// <param name="mapName">地图名。</param>
 /// <param name="geometry">几何对象。</param>
 /// <param name="spatialQueryMode">空间几何对象间的查询模式
 /// <para>空间几何对象间的查询模式定义了一些几何对象之间的空间位置关系,根据这些空间关系来构建过滤条件执行查询。</para>
 /// <example>查询可被包含在面对象中的空间对象,与面有相离或者相邻关系的空间对象等。</example>
 /// </param>
 /// <param name="queryParameterSet">查询参数集。可对某个地图的多个图层进行查询,单个图层的查询参数在queryParameters.queryParams[i]中进行设置。 </param>
 /// <returns>查询结果集。</returns>
 public QueryResult QueryByGeometry(string mapName, Geometry geometry, SpatialQueryMode spatialQueryMode, QueryParameterSet queryParameterSet)
 {
     if (string.IsNullOrEmpty(mapName)) throw new ArgumentNullException("mapName", Resources.ArgumentIsNotNull);
     QueryResource qrResource = new QueryResource();
     if (geometry != null)
     {
         qrResource.Geometry = geometry;
     }
     else
     {
         throw new ArgumentNullException("geometry", Resources.ArgumentIsNotNull);
     }
     if (queryParameterSet != null && queryParameterSet.QueryParams != null)
     {
         qrResource.QueryParameters = queryParameterSet;
     }
     else
     {
         throw new ArgumentNullException("queryParameterSet", Resources.ArgumentIsNotNull);
     }
     qrResource.QueryMode = "SpatialQuery";
     qrResource.SpatialQueryMode = spatialQueryMode.ToString();
     return QueryInternal(mapName, qrResource);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 获取与指定几何对象具有特定空间查询模式的要素。
 /// </summary>
 /// <param name="datasetNames">数据集名称数组(datasourceName:datasetName),如 World:Capitals,必选参数。</param>
 /// <param name="geometry">几何对象。</param>
 /// <param name="spatialQueryMode">空间查询模式。</param>
 /// <param name="attributeFilter">属性过滤条件。</param>
 /// <param name="fields">待返回的字段数组。当该参数为 null 时,返回全部字段。</param>
 /// <returns>要素集合。</returns>
 public List<Feature> GetFeature(string[] datasetNames, Geometry geometry, SpatialQueryMode spatialQueryMode, string attributeFilter, string[] fields)
 {
     if (datasetNames == null || datasetNames.Length <= 0 || string.IsNullOrEmpty(datasetNames[0]))
     {
         throw new ArgumentNullException("datasetNames", Resources.ArgumentIsNotNull);
     }
     if (geometry == null)
     {
         throw new ArgumentNullException("geometry", Resources.ArgumentIsNotNull);
     }
     GetFeatureResource featureResource = new GetFeatureResource();
     featureResource.DatasetNames = datasetNames;
     featureResource.Geometry = geometry;
     featureResource.SpatialQueryMode = spatialQueryMode;
     featureResource.AttributeFilter = attributeFilter;
     if (fields != null)
     {
         featureResource.QueryParameter = new QueryParameter();
         featureResource.QueryParameter.Fields = fields;
     }
     if (string.IsNullOrEmpty(attributeFilter))
     {
         featureResource.GetFeatureMode = GetFeatureMode.SPATIAL;
     }
     else
     {
         featureResource.GetFeatureMode = GetFeatureMode.SPATIAL_ATTRIBUTEFILTER;
     }
     return GetFeatureInternal(featureResource, 0);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 获取与指定几何对象具有特定空间查询模式的要素。
 /// </summary>
 /// <param name="datasetNames">数据集名称数组(datasourceName:datasetName),如 World:Capitals,必选参数。</param>
 /// <param name="geometry">几何对象。</param>
 /// <param name="spatialQueryMode">空间查询模式。</param>
 /// <param name="fields">待返回的字段数组。当该参数为 null 时,返回全部字段。</param>
 /// <returns>要素集合。</returns>
 public List<Feature> GetFeature(string[] datasetNames, Geometry geometry, SpatialQueryMode spatialQueryMode, string[] fields)
 {
     return GetFeature(datasetNames, geometry, spatialQueryMode, string.Empty, fields);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 获取与指定几何对象具有特定空间查询模式的要素。
 /// </summary>
 /// <param name="datasetNames">数据集名称数组(datasourceName:datasetName),如 World:Capitals,必选参数。</param>
 /// <param name="geometry">几何对象。</param>
 /// <param name="spatialQueryMode">空间查询模式。</param>
 /// <param name="attributeFilter">属性过滤条件。</param>
 /// <param name="fields">待返回的字段数组。当该参数为 null 时,返回全部字段。</param>
 /// <returns>要素集合。</returns>        
 /// <exception cref="ArgumentNullException">参数 datasetNames、geometry 为空时抛出异常。</exception>
 /// <exception cref="SuperMap.Connector.Utility.ServiceException">服务端处理错误时抛出异常。</exception>
 /// <example>
 /// 请参见:<see cref="GetFeature(string[], SuperMap.Connector.Utility.Geometry, SuperMap.Connector.Utility.SpatialQueryMode, string[])"/>
 /// </example>
 public List<Feature> GetFeature(string[] datasetNames, Geometry geometry, SpatialQueryMode spatialQueryMode, string attributeFilter, string[] fields)
 {
     return _dataProvider.GetFeature(datasetNames, geometry, spatialQueryMode, attributeFilter, fields);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 使用异步的方式,在指定的地图上,查询与指定的几何对象符合某种空间关系和查询条件的几何对象。
 /// </summary>
 /// <param name="mapName">地图名称。</param>
 /// <param name="geometry">几何对象。</param>
 /// <param name="spatialQueryMode">空间几何对象间的查询模式
 /// <para>空间几何对象间的查询模式定义了一些几何对象之间的空间位置关系,根据这些空间关系来构建过滤条件执行查询。
 /// 例如:查询可被包含在面对象中的空间对象,与面有相离或者相邻关系的空间对象等。</para>
 /// </param>
 /// <param name="queryParameterSet">查询参数集。可对某个地图的多个图层进行查询,单个图层的查询参数在queryParameters.queryParams[i]中进行设置。 </param>
 /// <param name="completed">在服务端查询完成后时执行的方法。</param>
 /// <param name="failed">在进行查询时发生异常后执行的方法。</param>
 public void QueryByGeometry(string mapName, Geometry geometry, SpatialQueryMode spatialQueryMode, QueryParameterSet queryParameterSet,
     EventHandler<QueryEventArgs> completed, EventHandler<FailedEventArgs> failed)
 {
     if (string.IsNullOrEmpty(mapName))
     {
         if (failed != null)
             failed(this, new FailedEventArgs(new ArgumentNullException("mapName", Resources.ArgumentIsNotNull)));
         return;
     }
     if (queryParameterSet == null)
     {
         if (failed != null)
         {
             failed(this, new FailedEventArgs(new ArgumentNullException("queryParameterSet", Resources.ArgumentIsNotNull)));
         }
         return;
     }
     if (geometry == null)
     {
         if (failed != null)
             failed(this, new FailedEventArgs(new ArgumentNullException("geometry", Resources.ArgumentIsNotNull)));
         return;
     }
     EventHandler<QueryEventArgs> callback = (sender, e) =>
     {
         if (completed != null)
         {
             completed(this, e);
         }
     };
     _mapProvider.QueryByGeometry(mapName, geometry, spatialQueryMode, queryParameterSet, callback, failed);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 在指定的地图上,查询与指定的几何对象符合某种空间关系和查询条件的几何对象。
 /// </summary>
 /// <param name="mapName">地图名称。</param>
 /// <param name="geometry">几何对象。</param>
 /// <param name="spatialQueryMode">空间几何对象间的查询模式
 /// <para>空间几何对象间的查询模式定义了一些几何对象之间的空间位置关系,根据这些空间关系来构建过滤条件执行查询。
 /// 例如:查询可被包含在面对象中的空间对象,与面有相离或者相邻关系的空间对象等。</para>
 /// </param>
 /// <param name="queryParameterSet">查询参数集。可对某个地图的多个图层进行查询,单个图层的查询参数在queryParameters.queryParams[i]中进行设置。 </param>
 /// <returns>查询结果集。</returns>
 public QueryResult QueryByGeometry(string mapName, Geometry geometry, SpatialQueryMode spatialQueryMode, QueryParameterSet queryParameterSet)
 {
     return _mapProvider.QueryByGeometry(mapName, geometry, spatialQueryMode, queryParameterSet);
 }