-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenTestData.go
38 lines (32 loc) · 918 Bytes
/
GenTestData.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
// GenTestData
package GridSearch
import (
"math/rand"
"time"
)
func GenRandomLo() int32 {
rand_ := rand.New(rand.NewSource(time.Now().UnixNano()))
return rand_.Int31n(CHINA_RECT.Right-CHINA_RECT.Left) + CHINA_RECT.Left
}
func GenRandomLa() int32 {
rand_ := rand.New(rand.NewSource(time.Now().UnixNano()))
return rand_.Int31n(CHINA_RECT.Top-CHINA_RECT.Bottom) + CHINA_RECT.Bottom
}
func GenRandomID() int32 {
rand_ := rand.New(rand.NewSource(time.Now().UnixNano()))
return rand_.Int31n(10000) * rand_.Int31n(20000) % 1234567890
}
func GenRandomRect() *rect {
rand1 := rand.New(rand.NewSource(time.Now().UnixNano()))
h := GRID_TOP_HEIGHT / (rand1.Int31n(100) + 10)
rand2 := rand.New(rand.NewSource(time.Now().UnixNano()))
w := GRID_TOP_WIDTH / (rand2.Int31n(100) + 10)
lo := GenRandomLo()
la := GenRandomLa()
return &rect{
lo,
la,
lo + w,
la - h,
}
}