package globe import ( "errors" "github.com/gogf/gf/v2/net/ghttp" "gorm.io/gorm" "net/http" "strconv" "sync" ) const ( ALL = -1 //所有 ENABLE = 1 DISABLE = 0 DESC = "desc" ASC = "asc" PAGE = 1 PAGESIZE = 10 ONLINE = 1 OFFLINE = 0 DEFAULTPWD = "123456" DEFAULTUSR = "admin" ) var DepartName = "一级部门" //默认的一级部门名称 var IS_OFFLINE_VERSION = true //是否为单机版本 const SOURCE = "static/source/" type WS_MAP map[string]*ghttp.WebSocket var WS_Status_map WS_MAP //状态数据ws var WS_Progress_drone_open_map WS_MAP //飞行器开机进度ws var WS_Progress_drone_close_map WS_MAP //飞行器关机进度ws var WS_Progress_cover_open_map WS_MAP //机库打开舱盖进度ws var WS_Progress_cover_close_map WS_MAP //机库关闭舱盖进度ws var WS_Progress_device_reboot_map WS_MAP //机库重启进度ws var WS_Progress_putter_open_map WS_MAP //推杆展开进度ws var WS_Progress_putter_close_map WS_MAP //推杆闭合进度ws var WS_Reply WS_MAP //状态恢复 var MutexRw sync.RWMutex //map的读写锁 const ( TILESET = "tileset" BIM = "bim" LAYER = "layer" TERRAIN = "terrain" POINT = "point" LINE = "line" AREA = "area" MODEL = "model" KML = "kml" GEOJSON = "geojson" ) const ( PAK = ".pak" MBTILES = ".mbtiles" CLT = ".clt" JCT = ".jct" ) var ( PORT = "80" HOST = "" PROTOCOL = "" KEY = "" CRT = "" ) const ( HTTP = "http" HTTPS = "https" ) func GetErrors(msg string) error { return errors.New(msg) } func GetAddr() string { //单机版本时 无代理,需要补全地址 if IS_OFFLINE_VERSION { return PROTOCOL + "://" + HOST + ":" + PORT + "/" } //网络版时 有代理 不需要补全地址 return "" } /*clt数据包*/ type Tile struct { MD5 string `json:"md5"` PATH string `json:"path"` Tile []byte `json:"tile"` Type string `json:"type"` } func RenderData(request *ghttp.Request, data []byte) { request.Response.Header().Set("Cache-Control", "private,max-age="+strconv.Itoa(60*60)) request.Response.WriteHeader(http.StatusOK) request.Response.Writer.Write(data) } func CloseDB(db *gorm.DB) { s, err := db.DB() if err != nil { return } s.Close() } var IS_AUTH_SUCCESS = false //是否授权通过 func CheckAuth() bool { return IS_AUTH_SUCCESS } func SetAuth(auth bool) { IS_AUTH_SUCCESS = auth } /*坐标点*/ type Point struct { Lng float64 `json:"lng" v:"required"` Lat float64 `json:"lat" v:"required"` Alt float64 `json:"alt" v:"required"` }