
I want to get the intersection point on a line from a outer point. I use mapinfo tables. if it is posibble how can I do ?



Hello,
you can try this
myLineGeometry.Intersects(myPointGeometry)
Be carefull, it's generaly impossible to retreive the intersection between a point and a line (whatever the GIS you use: MapInfo, ArcView,..) because the point should be exactly on the line.
Eric



Please note:
SharpMap.Geometries only check for bounding boxes. If you need true intersection testing use
NTS or you can use SharpMap.SqlServerSpatialObjects project.
Hth FObermaier


Sep 27, 2011 at 3:16 PM
Edited Sep 27, 2011 at 3:18 PM

private void FindIntersectPoint(SharpMap.Geometries.Point foundPoint,SharpMap.Geometries.LineString foundLine)
{
double growRate = 2;
SharpMap.Geometries.LinearRing circle = GeometryHelper.createEllipse(foundPoint, growRate, 12);
Boolean intersection = foundLine.GetBoundingBox().Intersects(circle.GetBoundingBox());
while (intersection!=true)
{
growRate += 1;
SharpMap.Geometries.Geometry circGeo= SharpMap.Converters.NTS.GeometryConverter.ToSharpMapGeometry(circle.GetBoundingBox());
if (foundLine.GetBoundingBox().Intersects(circGeo)== true)
{
SharpMap.Geometries.Geometry intersectPoints = foundLine.Intersection(circGeo); // I want to get intersection point
intersection = true;
}
}
}
it doesn't work



ms08 wrote:
it doesn't work
This is not sufficient. Please provide a testcase that proves your point. What are the initial arguments of foundPoint and foundLine?
Thanks FObermaier



SharpMap.Geometries.Point foundPoint = pnt1;// this point is out of the found line. It set from map click. utm coordinate.
SharpMap.Geometries.Geometry foundroad= vectorLayer.DataSource.GetGeometryByID(id);
SharpMap.Geometries.LineString line1 = foundRoadGeo as SharpMap.Geometries.LineString;
System.Collections.ObjectModel.Collection<double[]> pointsOfLine = new System.Collections.ObjectModel.Collection<double[]>();
pointsOfLine.Add(CoordinateHelper.ConvertWgsToUtm(line1.StartPoint.ToDoubleArray()));
pointsOfLine.Add(CoordinateHelper.ConvertWgsToUtm(line1.EndPoint.ToDoubleArray()));
SharpMap.Geometries.LineString line2= new SharpMap.Geometries.LineString(pointsOfLine);
FindIntersectPoint(foundPoint , line2);
/*************************************/
private void FindIntersectPoint(SharpMap.Geometries.Point foundPoint,SharpMap.Geometries.LineString foundLine)
{
double growRate = 2;
SharpMap.Geometries.LinearRing circle = GeometryHelper.createEllipse(foundPoint, growRate, 12);// draw
Boolean intersection = foundLine.GetBoundingBox().Intersects(circle.GetBoundingBox());
while (intersection!=true)
{
growRate += 1;
circle = GeometryHelper.createEllipse(foundPoint,growRate,12);// create ellipse for find intersection from line
if (foundLine.GetBoundingBox().Intersects(circGeo)== true)
{
SharpMap.Geometries.Geometry intersectPoints = foundLine.Intersection(circGeo); // I want to get intersection point
intersection = true;
}
}
}
****/ I want to find a nearest point on a line from a point that is out of the line.


Sep 28, 2011 at 9:25 AM
Edited Sep 28, 2011 at 10:09 AM

I added a png file this link. Maybe understand easily.
http://sharpmap.codeplex.com/workitem/31518



Again, you need to use NetTopologySuite do do that.
//1. convert sharpmap geometries to GeoAPI/NTS geometries.
var ntsPoint = ...
var ntsGeometry = ..
//2. create new DistanceOp
var nearestPoints = NetTopologySuite.Operation.Distance.DistanceOp.NearestPoints(ntsPoint, ntsGeometry);
//3. You will get an array of two ICoordinate instances, one representing ntsPoint
return nearestPoint[1];

