I am stuck at a problem for weeks, Please Help!!!
I am making program in C# Here is what I need to do --- I have two polylines that are intersecting with each other at some points. I want to delete those portion of one polyline which are going above the other polyline. I am attaching an image explaining the problem I am going through. In this image, I have two Polylines Line1 and Line2. So according to that image, I want to remove the dashed portions of Line2.
Please Help!!! Thanks a ton in advance
Here is what I have done till now.... First I am finding out all the points of intersection of the two lines and saving them in a layer.... Then I am Splitting these lines at these points using this code...
while (pPointF != null)
{
IPoint pPoint = (IPoint)pPointF.Shape;
ISpatialFilter pSF = new SpatialFilterClass();
pSF.Geometry = pPoint;
pSF.GeometryField = "Shape";
pSF.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
IFeatureCursor pLineCursor = pFeatureclass1.Search(pSF, true);
IFeature pLineF = pLineCursor.NextFeature();
while (pLineF != null)
{
IPolycurve pPolycurve = (IPolycurve)pLineF.Shape;
IPoint pToPoint = pPolycurve.ToPoint;
IPoint pFromPoint = pPolycurve.FromPoint;
if (pFromPoint.X != pPoint.X && pFromPoint.Y != pPoint.Y && pToPoint.X != pPoint.X && pToPoint.Y != pPoint.Y)
{
IFeatureEdit pFeatureEdit = (IFeatureEdit)pLineF;
pFeatureEdit.Split(pPoint);
}
pLineF = pLineCursor.NextFeature();
}
}
The problem with this code that it is giving different results than expected. As I can see from attribute table, it is generating more than expected parts of line i.e. if there are 5 intersection points then there should be 6 parts of a line, nut it is creating 10-12 parts. Also the number of parts created for both lines are different, which logically should be same. Due to these problems, when I am trying to delete unwanted parts of line, the arcGis crashes..... Please help with this problem. . . . Now I am using a Geoprocessor to do splitting, following is the code:
SplitLineAtPoint pSplitter = new SplitLineAtPoint();
pSplitter.in_features = pPolylayer1;
pSplitter.point_features = pPointsFeatureLayer;
string outfile = txtDirName.Text + "\\" + "splitted";
pSplitter.out_feature_class = @outfile;
Geoprocessor GeoPro = new Geoprocessor();
GeoPro.Execute(pSplitter, null);
But on the last line, where Geoprocessor is being executed, the ArcGIS crashes... Please tell me where is the problem...
Split()
. I think this method is meant more for interactive splitting of one feature with one point at a time, not for multiple splitting of many features with many points. For that try IPolycurve2.SplitAtPoints