本文整理汇总了Golang中gopnik.TileCoord类的典型用法代码示例。如果您正苦于以下问题:Golang TileCoord类的具体用法?Golang TileCoord怎么用?Golang TileCoord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TileCoord类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestQueueDub
func TestQueueDub(t *testing.T) {
rq := newRenderQueue(10)
coordA := gopnik.TileCoord{
X: 10,
Y: 7,
Zoom: 11,
}
coordB := gopnik.TileCoord{
X: 10,
Y: 7,
Zoom: 11,
}
resCh := make(chan *RenderPoolResponse, 1)
go func() {
err := rq.Push(coordA, resCh)
if err != nil {
t.Errorf("Push error: %v", err)
}
err = rq.Push(coordB, resCh)
if err != nil {
t.Errorf("Push error: %v", err)
}
}()
coord2 := <-rq.TasksChan()
if !coordA.Equals(&coord2) {
t.Error("Coordinates not equal")
}
}
示例2: TestRoute
func TestRoute(t *testing.T) {
renders := []string{"localhost:9001", "localhost:9002", "localhost:9003"}
for _, r := range renders {
go runFakeRender(r)
}
time.Sleep(100 * time.Millisecond)
rs, err := NewRenderSelector(renders, time.Second, 30*time.Second)
require.Nil(t, err)
defer rs.Stop()
coord := gopnik.TileCoord{
X: 0,
Y: 0,
Zoom: 1,
Size: 1,
}
back1, err1 := rs.SelectRender(coord)
require.Nil(t, err1)
coord.X = 3
back2, err2 := rs.SelectRender(coord)
require.Nil(t, err2)
coord.Y = 4
back3, err3 := rs.SelectRender(coord)
require.Nil(t, err3)
coord.Zoom = 5
back4, err4 := rs.SelectRender(coord)
require.Nil(t, err4)
require.True(t,
back1.Addr != back2.Addr || back1.Addr != back3.Addr || back1.Addr != back4.Addr,
)
}
示例3: setStatus
func (self *plan) setStatus(coord gopnik.TileCoord, status uint8) error {
self.mu.Lock()
defer self.mu.Unlock()
for i, c := range self.bboxes {
if coord.Equals(&c) {
self.status[i] = status
self.cond.Broadcast()
return nil
}
}
return fmt.Errorf("Can't find task %v", coord)
}
示例4: TestQueueWaitMulti
func TestQueueWaitMulti(t *testing.T) {
rq := newRenderQueue(10)
coordA := gopnik.TileCoord{
X: 10,
Y: 7,
Zoom: 11,
}
coordB := gopnik.TileCoord{
X: 3,
Y: 5,
Zoom: 12,
}
coordC := gopnik.TileCoord{
X: 3,
Y: 5,
Zoom: 12,
Size: 4,
}
resCh := make(chan *RenderPoolResponse, 10)
go func() {
time.Sleep(1 * time.Millisecond)
err := rq.Push(coordA, resCh)
if err != nil {
t.Errorf("Push error: %v", err)
}
time.Sleep(1 * time.Millisecond)
err = rq.Push(coordB, resCh)
if err != nil {
t.Errorf("Push error: %v", err)
}
time.Sleep(1 * time.Millisecond)
err = rq.Push(coordC, resCh)
if err != nil {
t.Errorf("Push error: %v", err)
}
}()
coordA2 := <-rq.TasksChan()
if !coordA.Equals(&coordA2) {
t.Errorf("Coordinates not equal: %v != %v", coordA2, coordA)
}
coordB2 := <-rq.TasksChan()
if !coordB.Equals(&coordB2) {
t.Errorf("Coordinates not equal: %v != %v", coordB2, coordB)
}
coordC2 := <-rq.TasksChan()
if !coordC.Equals(&coordC2) {
t.Errorf("Coordinates not equal: %v != %v", coordC2, coordC)
}
}
示例5: applyFilterItem
func (self *BBoxTagFilterPlugin) applyFilterItem(coord *gopnik.TileCoord, fi *filterItem, inBb bool) {
if inBb {
for _, tag := range fi.Drop {
coord.Tags = strArrDrop(coord.Tags, tag)
}
for _, tag := range fi.Add {
coord.Tags = strArrAdd(coord.Tags, tag)
}
} else {
for _, tag := range fi.DropOtherwise {
coord.Tags = strArrDrop(coord.Tags, tag)
}
for _, tag := range fi.AddOtherwise {
coord.Tags = strArrAdd(coord.Tags, tag)
}
}
}
示例6: runWebUI
func runWebUI(addr string, perfData []perflog.PerfLogEntry) {
m := staticbin.Classic(gopnikwebstatic.Asset)
m.Map(log.New(os.Stderr, "", log.LstdFlags))
m.Use(rendergold.Renderer(rendergold.Options{Asset: Asset}))
m.Get("/", func(r rendergold.Render) {
totalStats := getStats(perfData, nil)
var zoomsStats []zoomStats
zrng := getZooms(perfData)
for z := zrng.MinZoom; z <= zrng.MaxZoom; z++ {
zoomsStats = append(zoomsStats, zoomStats{
Zoom: z,
Stats: getStats(perfData, &z),
})
}
r.HTML(
http.StatusOK,
"index",
map[string]interface{}{
"Page": "Results",
"TotalStats": totalStats,
"ZoomsStats": zoomsStats,
},
)
})
m.Get("/heatmap", func(r rendergold.Render) {
r.HTML(
http.StatusOK,
"heatmap",
map[string]interface{}{
"Page": "Heat",
},
)
})
m.Get("/heattiles_zooms", func(res http.ResponseWriter) {
var zooms struct {
Min uint64
Max uint64
}
if len(perfData) > 0 {
zooms.Min = perfData[0].Coord.Zoom
zooms.Max = perfData[0].Coord.Zoom
for i := 1; i < len(perfData); i++ {
zoom := perfData[i].Coord.Zoom
if zoom < zooms.Min {
zooms.Min = zoom
}
if zoom > zooms.Max {
zooms.Max = zoom
}
}
}
enc := json.NewEncoder(res)
if err := enc.Encode(zooms); err != nil {
http.Error(res, err.Error(), 500)
return
}
})
m.Get("/heattiles/:zoom_orig/:zoom/:x/:y.png", func(params martini.Params, res http.ResponseWriter) {
var coord gopnik.TileCoord
coord.Size = 1
_, err := fmt.Sscan(params["zoom"], &coord.Zoom)
if err != nil {
http.Error(res, err.Error(), 400)
return
}
_, err = fmt.Sscan(params["x"], &coord.X)
if err != nil {
http.Error(res, err.Error(), 400)
return
}
_, err = fmt.Sscan(params["y"], &coord.Y)
if err != nil {
http.Error(res, err.Error(), 400)
return
}
var zoomOrig uint64
_, err = fmt.Sscan(params["zoom_orig"], &zoomOrig)
if err != nil {
http.Error(res, err.Error(), 400)
return
}
tile, err := genPerfTile(perfData, coord, zoomOrig)
if err != nil {
http.Error(res, err.Error(), 500)
return
}
//.........这里部分代码省略.........