您好我正在尝试创建一个函数,该函数将选择图层几何形状并更改其颜色或突出显示它。
我找到了这个FindGeoNearPoint
函数,但它处理的是旧SharpMap.Geometries
的 whih 不再存在,并已被 GeoAPI.Geometries 取代。
如何更改FindGeoNearPoint
函数以使用 GeoAPI
这是我的尝试
public SharpMap.Data.FeatureDataRow FindGeoNearPoint(GeoAPI.Geometries.IPoint pos, SharpMap.Layers.VectorLayer layer, double amountGrow)
{
GeoAPI.Geometries.Envelope bbox = new GeoAPI.Geometries.Envelope();
SharpMap.Data.FeatureDataSet ds = new SharpMap.Data.FeatureDataSet();
layer.DataSource.ExecuteIntersectionQuery(bbox, ds);
DataTable tbl = ds.Tables[0] as SharpMap.Data.FeatureDataTable;
NetTopologySuite.IO.WKTReader reader = new NetTopologySuite.IO.WKTReader();
GeoAPI.Geometries.IGeometry point = reader.Read(pos.ToString());
if (tbl.Rows.Count == 0)
return null;
double distance = point.Distance(reader.Read((tbl.Rows[0] as SharpMap.Data.FeatureDataRow).Geometry.ToString()));
SharpMap.Data.FeatureDataRow selectedFeature = tbl.Rows[0] as SharpMap.Data.FeatureDataRow;
if (tbl.Rows.Count > 1)
for (int i = 1; i < tbl.Rows.Count; i++)
{
GeoAPI.Geometries.IGeometry line = reader.Read((tbl.Rows[i] as SharpMap.Data.FeatureDataRow).Geometry.ToString());
if (point.Distance(line) < distance)
{
distance = point.Distance(line);
selectedFeature = tbl.Rows[i] as SharpMap.Data.FeatureDataRow;
}
}
return selectedFeature;
}