-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathExporter.lua
More file actions
22 lines (20 loc) · 990 Bytes
/
Exporter.lua
File metadata and controls
22 lines (20 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- Export the generated course or parts of it
Exporter = CpObject()
---@param fieldworkCourse CourseGenerator.FieldworkCourse
function Exporter:init(fieldworkCourse)
self.fieldworkCourse = fieldworkCourse
end
--- Export a headland as a CSV file. Only includes the given headland, without the connecting path or transitions.
---@param headlandNumber number The headland to export, 1 is the outermost
---@param filename string The filename to save the CSV file as, under the export/ directory
function Exporter:exportHeadlandAsCsv(headlandNumber, filename)
local file = io.open('export/' .. filename, 'w')
for _, v in self.fieldworkCourse:getHeadlandPath():vertices() do
if v:getAttributes():getHeadlandPassNumber() == headlandNumber and
not v:getAttributes():isHeadlandTransition() and
not v:getAttributes():isOnConnectingPath() then
file:write(string.format('%.2f,%.2f\n', v.x, v.y))
end
end
file:close()
end