首页 / 浏览问题 / 组件GIS / 问题详情
怎么筛选矢量数据集上的相关数据
7EXP 2025年07月10日

问题描述:winform添加矢量数据shp文件,根据属性列进行筛选,将筛选后的值显示到底图上,目前筛选后还是显示多个数据,这块不知道具体怎么做筛选

ImportDataInfos dataInfos = shpSetting.GetTargetDataInfos("");
ImportDataInfoSHP info = dataInfos[0] as ImportDataInfoSHP;
info.TargetName = "TransportsTest";
shpSetting.SetTargetDataInfos(dataInfos);
m_dataImport.ImportSettings.Add(shpSetting);
m_dataImport.Run();
DatasetVector importResult = datasources.Datasets["TransportsTest"] as DatasetVector;

if (mapControl.Map.PrjCoordSys != importResult.PrjCoordSys)
    mapControl.Map.IsDynamicProjection = true;
// 2. 创建样式对象(根据数据类型设置)
GeoStyle style = new GeoStyle();

LayerSettingVector layerSetting = new LayerSettingVector();
layerSetting.Style = style;
QueryParameter queryParam = new QueryParameter
{
    AttributeFilter = "fclass = 'railway_station'",
    CursorType = SuperMap.Data.CursorType.Static
};

// 执行查询
//Recordset recordset = importResult.Query(queryParam);
Recordset recordset = importResult.Query("fid=1",CursorType.Static);
string filterName = $"Railway_Station";
if (datasources.Datasets.Contains(filterName))
    datasources.Datasets.Delete(filterName);

//DatasetVectorInfo datasetVectorInfo = new DatasetVectorInfo();
datasetVectorInfo.Name = filterName;
DatasetVector vector = datasources.Datasets.Create(datasetVectorInfo);
vector.Append(recordset);
// 将空间查询结果追加到新建的数据集中
Layer layer = mapControl.Map.Layers.Add(vector, layerSetting, true);
// 4. 设置图层名称
//layer.Caption = "交通路线";
ThemeLabel themeLabel = new ThemeLabel();
themeLabel.LabelExpression = "name";
TextStyle textStyle = new TextStyle();

themeLabel.UniformStyle = textStyle;
// 将制作好的专题图添加到地图中显示
mapControl.Map.Layers.Add(importResult, themeLabel, true);
mapControl.Map.ViewEntire();
mapControl.Map.Refresh();
recordset.Close();
recordset.Dispose();
vector.Close();

1个回答

您好,图层过滤显示,可以使用layer的displayfilter方法
1,360EXP 2025年07月10日
...