@@ -139,10 +139,10 @@ function FieldworkCourse:generateHeadlands()
139139 if self .nHeadlands > self .nHeadlandsWithRoundCorners and # self .headlands < self .nHeadlands then
140140 self :generateHeadlandsFromOutside (self .boundary ,
141141 self :_getHeadlandOffset (self .nHeadlandsWithRoundCorners + 1 ),
142- # self .headlands + 1 )
142+ # self .headlands + 1 , self . headlands [ 1 ] and self . headlands [ 1 ]: getPolygon () )
143143 end
144144 elseif self .nHeadlands > 0 then
145- self :generateHeadlandsFromOutside (self .boundary , self :_getHeadlandOffset (1 ), 1 )
145+ self :generateHeadlandsFromOutside (self .boundary , self :_getHeadlandOffset (1 ), 1 , self . boundary )
146146 end
147147end
148148
@@ -151,12 +151,15 @@ end
151151--- @param firstHeadlandWidth number width of the outermost headland to generate , if the boundary is the field boundary ,
152152--- it will usually be the half working width, if the boundary is another headland, the full working width
153153--- @param startIx number index of the first headland to generate
154- function FieldworkCourse :generateHeadlandsFromOutside (boundary , firstHeadlandWidth , startIx )
154+ --- @param mustNotCross Polygon | nil polygon which the outermost generated headland must not cross , usually the innermost
155+ --- headland generated with rounded corners, or the field boundary itself when there are no rounded headlands.
156+ function FieldworkCourse :generateHeadlandsFromOutside (boundary , firstHeadlandWidth , startIx , mustNotCross )
155157
156158 self .logger :debug (' generating %d sharp headlands from the outside, first width %.1f, start at %d, min radius %.1f' ,
157159 self .nHeadlands - startIx + 1 , firstHeadlandWidth , startIx , self .context .turningRadius )
158160 -- outermost headland is offset from the field boundary by half width
159- self .headlands [startIx ] = CourseGenerator .Headland (boundary , self .context .headlandClockwise , startIx , firstHeadlandWidth , false , nil )
161+ self .headlands [startIx ] = CourseGenerator .Headland (boundary , self .context .headlandClockwise , startIx ,
162+ firstHeadlandWidth , false , mustNotCross )
160163 if not self .headlands [startIx ]:isValid () then
161164 self :_removeHeadland (startIx )
162165 return
0 commit comments