From 5cb53f7064acab1c58f0020e620e1f9ee2f1d5d9 Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期四, 07 十一月 2019 10:32:55 +0800
Subject: [PATCH] 推送视频地址新方案(不推送)

---
 ruleserver/geoPolygon_test.go |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/ruleserver/geoPolygon_test.go b/ruleserver/geoPolygon_test.go
new file mode 100644
index 0000000..7f6c9ee
--- /dev/null
+++ b/ruleserver/geoPolygon_test.go
@@ -0,0 +1,38 @@
+package ruleserver
+
+import (
+	"basic.com/valib/logger.git"
+	"encoding/json"
+	"fmt"
+	"ruleprocess/structure"
+
+	"testing"
+)
+
+func TestPgsInterPercent(t *testing.T) {
+	areaPoints := json2points("[{\"x\":582,\"y\":11},{\"x\":582,\"y\":525},{\"x\":943,\"y\":525},{\"x\":943,\"y\":11}]")
+	widthScale := float64(2688) / 960
+	heigthScale := float64(1520) / 540
+	rec := structure.Rect{1333, 594,204,274}
+	per := PgsInterPercent(areaPoints,rec,widthScale,heigthScale)
+	fmt.Println(widthScale,heigthScale,per)
+}
+
+// 灏嗗瓧绗︿覆鏍煎紡鐨勫潗鏍囧簭鍒楀寲涓篜oint鏍煎紡
+func json2points(areaPoints string) []Point {
+	var pts []Point
+	if areaPoints == "[]" || areaPoints == "" {
+		logger.Error("=====================姝ゅ尯鍩熶负鍏ㄩ儴鍖哄煙")
+		pts = append(pts, Point{0, 0})
+		pts = append(pts, Point{0, 540})
+		pts = append(pts, Point{960, 540})
+		pts = append(pts, Point{960, 0})
+	} else {
+		err := json.Unmarshal([]byte(areaPoints), &pts)
+		if err != nil {
+			logger.Error("json.Unmarshal閿欒", err)
+			panic("搴忓垪鍖栧潗鏍囧紓甯革紝绋嬪簭閫�鍑�")
+		}
+	}
+	return pts
+}
\ No newline at end of file

--
Gitblit v1.8.0