package globe import ( "errors" "github.com/gogf/gf/v2/net/ghttp" "gorm.io/gorm" "net/http" "strconv" ) const ( ALL = -1 //所有 ENABLE = 1 DISABLE = 0 DESC = "desc" ASC = "asc" PAGE = 1 PAGESIZE = 10 ONLINE = 1 OFFLINE = 0 PREFFIX = "yjearth4.0" ) var IS_OFFLINE_VERSION = true //是否为单机版本 const SOURCE = "resource/public/clt/" const ( TILESET = "tileset" BIM = "bim" LAYER = "layer" TERRAIN = "terrain" POINT = "point" LINE = "line" AREA = "area" MODEL = "model" KML = "kml" GEOJSON = "geojson" DIRECTORY = "directory" SHP = "shp" ) const ( PAK = ".pak" MBTILES = ".mbtiles" CLT = ".clt" JCT = ".jct" DOTGEOJSON = ".geojson" DOTSHP = ".shp" ) 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 + "/" + PREFFIX //} //网络版时 有代理 不需要补全地址 return PREFFIX } /*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() }