初始
This commit is contained in:
78
third/plane/wayline/template/template.go
Normal file
78
third/plane/wayline/template/template.go
Normal file
@ -0,0 +1,78 @@
|
||||
package template
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/tiger1103/gfast/v3/third/plane/wayline/struct"
|
||||
"os"
|
||||
)
|
||||
|
||||
func CreateWayPointTempalteWpml() {
|
||||
|
||||
}
|
||||
|
||||
func CreateWayPointTempalteKml() {
|
||||
kml := _struct.KML{
|
||||
//XmlnsStream: "http://www.dji.com/wpmz/1.0.3",
|
||||
Document: _struct.Doc{
|
||||
Author: "重庆远界大数据研究院有限公司",
|
||||
CreateTime: gtime.Now().TimestampMilli(),
|
||||
UpdateTime: gtime.Now().TimestampMilli(),
|
||||
},
|
||||
}
|
||||
msconfig := _struct.MissionConfig{
|
||||
FlyToWaylineMode: _struct.Safely,
|
||||
FinishAction: _struct.GoHome,
|
||||
ExitOnRCLost: _struct.ExecuteLostAction,
|
||||
ExecuteRCLostAction: _struct.Hover,
|
||||
TakeOffSecurityHeight: 5,
|
||||
GlobalTransitionalSpeed: 5,
|
||||
GlobalRTHHeight: 5,
|
||||
}
|
||||
//设置公共配置
|
||||
kml.Document.MissionConfig = msconfig
|
||||
tp := _struct.WayPointTemplate{}
|
||||
|
||||
tp.TemplateType = _struct.Waypoint //航点飞行
|
||||
tp.TemplateId = 0 //模板ID * 注:在一个kmz文件内该ID唯一。建议从0开始单调连续递增。在template.kml和waylines.wpml文件中,将使用该id将模板与所生成的可执行航线进行关联。
|
||||
tp.AutoFlightSpeed = 5 //全局航线飞行速度
|
||||
|
||||
tp.WaylineCoordinateSysParam.CoordinateMode = "WGS84"
|
||||
tp.WaylineCoordinateSysParam.HeightMode = "EGM96"
|
||||
tp.WaylineCoordinateSysParam.PositioningType = "GPS"
|
||||
tp.WaylineCoordinateSysParam.SurfaceFollowModeEnable = 0
|
||||
|
||||
tp.GlobalHeight = 100
|
||||
|
||||
kml.Document.Folder = tp
|
||||
createXML(kml, "template.xml")
|
||||
}
|
||||
|
||||
func createXML(v interface{}, file string) {
|
||||
// 生成 XML
|
||||
xmlBytes, err := xml.MarshalIndent(v, "", " ")
|
||||
if err != nil {
|
||||
fmt.Println("生成XML失败:", err)
|
||||
return
|
||||
}
|
||||
// 将 XML 写入文件
|
||||
xmlFile, err := os.Create(file)
|
||||
if err != nil {
|
||||
fmt.Println("创建文件失败:", err)
|
||||
return
|
||||
}
|
||||
defer xmlFile.Close()
|
||||
xmlWithVersion := []byte(xml.Header + string(xmlBytes))
|
||||
_, err = xmlFile.Write(xmlWithVersion)
|
||||
if err != nil {
|
||||
fmt.Println("写入文件失败:", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("生成的KML文件:output.kml")
|
||||
}
|
||||
|
||||
//func CreateWayPointTempalte(points []globe.Point) {
|
||||
//
|
||||
//}
|
Reference in New Issue
Block a user