From 461919b86da883133ddc6d30bf684539cc0d3b1a Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期二, 02 七月 2019 10:34:38 +0800
Subject: [PATCH] 改用画线方式
---
cache/cache.go | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/cache/cache.go b/cache/cache.go
index 4a399f8..f72a1e0 100644
--- a/cache/cache.go
+++ b/cache/cache.go
@@ -20,8 +20,9 @@
func Init(initChan chan bool,dbIp string,surveyPort int,pubSubPort int){
- urlSurvey := dbIp + strconv.Itoa(surveyPort)
- urlPubSub := dbIp + strconv.Itoa(pubSubPort)
+ cMap = shardmap.New(uint8(32))
+ urlSurvey := "tcp://" + dbIp + ":" + strconv.Itoa(surveyPort)
+ urlPubSub := "tcp://" + dbIp + ":" + strconv.Itoa(pubSubPort)
client, _ := gopherdiscovery.ClientWithSub(urlSurvey, urlPubSub, uuid.NewV4().String())
recvMsg := client.HeartBeatMsg()
fmt.Println(<-recvMsg)
@@ -70,14 +71,16 @@
var api dbapi.CameraApi
data := api.FindAllPolygons()
for _, item := range data {
- cameraId :=item.CameraId
- arr, b := cMap.Get(PREFIX_POLYGON + cameraId)
- if b {
- list := arr.([]protomsg.CameraPolygon)
- list = append(list,item)
- cMap.Set(PREFIX_POLYGON + cameraId,list)
- } else {
- cMap.Set(PREFIX_POLYGON + cameraId,[]protomsg.CameraPolygon{ item })
+ if item.Type != "line" {
+ cameraId :=item.CameraId
+ arr, b := cMap.Get(PREFIX_POLYGON + cameraId)
+ if b {
+ list := arr.([]protomsg.CameraPolygon)
+ list = append(list,item)
+ cMap.Set(PREFIX_POLYGON + cameraId,list)
+ } else {
+ cMap.Set(PREFIX_POLYGON + cameraId,[]protomsg.CameraPolygon{ item })
+ }
}
}
}
--
Gitblit v1.8.0