this does not work either ... any ideas ?
:(
http://pastebin.com/m3de539d
1.
Private Function SplitFuncLAST(ByVal splitPoint As
GisSharpBlog.NetTopologySuite.Geometries.Geometry, ByVal lineToSplit
As GisSharpBlog.NetTopologySuite.Geometries.Geometry, ByRef
RightSegment As GisSharpBlog.NetTopologySuite.Geometries.LineString,
ByRef LeftSegment As
GisSharpBlog.NetTopologySuite.Geometries.LineString) As Boolean
2.
'what you could do instead is loop through
3.
'each pair of coordinates -
4.
'create a new line string geometry -
5.
'do an intersection test between the point and the line
string etc
6.
Dim splitPointCoordinate As ICoordinate =
splitPoint.Coordinate
7.
Dim splitPointNTS As
GisSharpBlog.NetTopologySuite.Geometries.Point = GSfactory.CreatePoint
(splitPointCoordinate)
8.
9.
Dim seperationOnIndex As Integer = -1
10.
For CoordIndex As Integer = 0 To
lineToSplit.Coordinates.Length - 2
11.
Dim coord1 As ICoordinate = lineToSplit.Coordinates
(CoordIndex)
12.
Dim coord2 As ICoordinate = lineToSplit.Coordinates
(CoordIndex + 1)
13.
14.
Dim point1 As
GisSharpBlog.NetTopologySuite.Geometries.Point = GSfactory.CreatePoint
(coord1)
15.
Dim point2 As
GisSharpBlog.NetTopologySuite.Geometries.Point = GSfactory.CreatePoint
(coord2)
16.
17.
Dim vertices(1) As ICoordinate
18.
vertices(0) = point1.Coordinate
19.
vertices(1) = point2.Coordinate
20.
Dim thisLineString As New
GisSharpBlog.NetTopologySuite.Geometries.LineString(vertices)
21.
Dim CHECK As Boolean = thisLineString.Intersects
(splitPointNTS)
22.
If CHECK Then
23.
seperationOnIndex = CoordIndex
24.
End If
25.
26.
27.
Next
28.
29.
If seperationOnIndex = -1 Then
30.
'Didn't find anything!
31.
Return False
32.
End If
33.
34.
35.
'-------------------------------------------------------------
36.
Dim myLeftCoords As New List(Of
GeoAPI.Geometries.ICoordinate)
37.
Dim myRightCoords As New List(Of
GeoAPI.Geometries.ICoordinate)
38.
'add the intersection point at the beginning of
myRightCoords
39.
myRightCoords.Add(splitPointCoordinate)
40.
For CoordIndex As Integer = 0 To
lineToSplit.Coordinates.Length - 1
41.
Dim coord As GeoAPI.Geometries.ICoordinate =
lineToSplit.Coordinates(CoordIndex)
42.
43.
'myLeftCoords should include the coordinates from 0
up to and including seperationIndex
44.
If CoordIndex <= seperationOnIndex Then
45.
myLeftCoords.Add(coord)
46.
End If
47.
48.
'myRightCoords should include all the coordinates
Greater than separationIndex
49.
If CoordIndex > seperationOnIndex Then
50.
myRightCoords.Add(coord)
51.
End If
52.
Next
53.
'-------------------------------------------------------------
54.
55.
'add the intersection point at
56.
'the end of myLeftCoords
57.
myLeftCoords.Add(splitPointCoordinate)
58.
LeftSegment = New
GisSharpBlog.NetTopologySuite.Geometries.LineString
(myLeftCoords.ToArray)
59.
RightSegment = New
GisSharpBlog.NetTopologySuite.Geometries.LineString
(myRightCoords.ToArray)
60.
Return True
61.
End Function