-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsds_types.go
151 lines (135 loc) · 5.57 KB
/
sds_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package main
import (
"encoding/binary"
"io"
"math"
)
type Zminzmax struct {
Zmin float64
Zmax float64
}
type rdsRequest struct {
TileRequest bool
FileFormat string
FileName string
FileType, FileSubsize int
FileXSize, FileYSize int
FileDataSize float64
FileDataOffset int
TileXSize, TileYSize, DecXMode, DecYMode, TileX, TileY int
DecX, DecY int
Zset bool
Subsize int
SubsizeSet bool
Transform string
ColorMap string
Reader io.ReadSeeker
Cxmode string
CxmodeSet bool
OutputFmt string
Outxsize int `json:"outxsize"`
Outysize int `json:"outysize"`
Outzsize int `json:"outzsize"`
Zmin float64 `json:"zmin"`
Zmax float64 `json:"zmax"`
Filexstart float64 `json:"filexstart"`
Filexdelta float64 `json:"filexdelta"`
Fileystart float64 `json:"fileystart"`
Fileydelta float64 `json:"fileydelta"`
Xstart int `json:"xstart"`
Xsize int `json:"xsize"`
Ystart int `json:"ystart"`
Ysize int `json:"ysize"`
X1, X2, Y1, Y2 int
}
func (request *rdsRequest) computeYSize() {
request.FileYSize = int(float64(request.FileDataSize)/bytesPerAtomMap[string(request.FileFormat[1])]) / (request.FileXSize)
if string(request.FileFormat[0]) == "C" {
request.FileYSize = request.FileYSize / 2
}
}
func (request *rdsRequest) computeTileSizes() {
request.DecX = decimationLookup[request.DecXMode]
request.DecY = decimationLookup[request.DecYMode]
request.Xstart = request.TileX * request.TileXSize * request.DecX
request.Ystart = request.TileY * request.TileYSize * request.DecY
request.Xsize = int(request.TileXSize * request.DecX)
request.Ysize = int(request.TileYSize * request.DecY)
request.Outxsize = request.TileXSize
request.Outysize = request.TileYSize
}
func (request *rdsRequest) computeRequestSizes() {
request.Ystart = int(math.Min(float64(request.Y1), float64(request.Y2)))
request.Xstart = int(math.Min(float64(request.X1), float64(request.X2)))
request.Xsize = int(math.Abs(float64(request.X2) - float64(request.X1)))
request.Ysize = int(math.Abs(float64(request.Y2) - float64(request.Y1)))
}
func (request *rdsRequest) processBlueFileHeader() {
var bluefileheader BlueHeader
binary.Read(request.Reader, binary.LittleEndian, &bluefileheader)
request.FileFormat = string(bluefileheader.Format[:])
request.FileType = int(bluefileheader.File_type)
request.FileXSize = int(bluefileheader.Subsize)
request.Filexstart = bluefileheader.Xstart
request.Filexdelta = bluefileheader.Xdelta
request.Fileystart = bluefileheader.Ystart
request.Fileydelta = bluefileheader.Ydelta
request.FileDataOffset = int(bluefileheader.Data_start)
request.FileDataSize = bluefileheader.Data_size
}
var zminzmaxFileMap map[string]Zminzmax
var decimationLookup = map[int]int{
1: 1,
2: 2,
3: 4,
4: 8,
5: 16,
6: 32,
7: 64,
8: 128,
9: 256,
10: 512,
}
var bytesPerAtomMap = map[string]float64{
"P": .125,
"B": 1,
"I": 2,
"L": 4,
"F": 4,
"D": 8,
}
type Location struct {
LocationName string `json:"locationName"`
LocationType string `json:"locationType"`
Path string `json:"path,omitempty"`
MinioBucket string `json:"minioBucket,omitempty"`
Location string `json:"location,omitempty"`
MinioAccessKey string `json:"minioAccessKey,omitempty"`
MinioSecretKey string `json:"minioSecretKey,omitempty"`
MinioUseSSL bool `json:"minioUseSSL,omitempty"`
}
// Configuration Struct for Configuraion File
type Configuration struct {
Port int `json:"port"`
CacheLocation string `json:"cacheLocation"`
Logfile string `json:"logfile"`
CacheMaxBytes int64 `json:"cacheMaxBytes"`
CheckCacheEvery int `json:"checkCacheEvery"`
MaxBytesZminZmax int `json:"maxBytesZminZmax"`
LocationDetails []Location `json:"locationDetails"`
}
type fileMetaData struct {
Outxsize int `json:"outxsize"`
Outysize int `json:"outysize"`
Outzsize int `json:"outzsize"`
Zmin float64 `json:"zmin"`
Zmax float64 `json:"zmax"`
Filexstart float64 `json:"filexstart"`
Filexdelta float64 `json:"filexdelta"`
Fileystart float64 `json:"fileystart"`
Fileydelta float64 `json:"fileydelta"`
Xstart int `json:"xstart"`
Xsize int `json:"xsize"`
Ystart int `json:"ystart"`
Ysize int `json:"ysize"`
}