39 lines
732 B
Go
39 lines
732 B
Go
package producer
|
|
|
|
type GridPoint struct {
|
|
Row, Col, H int
|
|
}
|
|
|
|
func gridImage(m, n, height, width, k, hmin, hmax int) []*GridPoint {
|
|
a := int(height / (m + 1))
|
|
var lines []int
|
|
for i := 0; i < m; i++ {
|
|
lines = append(lines, a*(i+1))
|
|
}
|
|
|
|
b := int(width / (n + 1))
|
|
var samples []int
|
|
for i := 0; i < n; i++ {
|
|
samples = append(samples, b*(i+1))
|
|
}
|
|
|
|
averageH := (hmax - hmin) / 2
|
|
dh := 500 // 高度差500m
|
|
var h []int
|
|
for i := 0; i < k; i++ {
|
|
h = append(h, averageH+(i-k/2)*dh)
|
|
}
|
|
|
|
var points []*GridPoint
|
|
for i := 0; i < len(lines); i++ {
|
|
for j := 0; j < len(samples); j++ {
|
|
for l := 0; l < len(h); l++ {
|
|
p := GridPoint{lines[i], samples[j], h[l]}
|
|
points = append(points, &p)
|
|
}
|
|
}
|
|
}
|
|
|
|
return points
|
|
}
|