hi there i'm trying to create a function that will select a layers geometry and change its colour or highlight it.
I've found the FindGeoNearPoint
function but this deals with the old SharpMap.Geometries
whih no longer exists and has been replaced with GeoAPI.Geometries.
How do I alter the FindGeoNearPoint
Function to use GeoAPI
Here is my attempt
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;
}