From b9d95191e0326a1a75f3809d75b94638c47c3d43 Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期一, 16 十二月 2019 16:58:51 +0800
Subject: [PATCH] ---

---
 ruleserver/geoPolygon.go |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/ruleserver/geoPolygon.go b/ruleserver/geoPolygon.go
index ae81c44..bb74b6c 100644
--- a/ruleserver/geoPolygon.go
+++ b/ruleserver/geoPolygon.go
@@ -20,10 +20,24 @@
 	return num1
 }
 
+//Rect 妫�娴嬬洰鏍�
+type Rect struct {
+	X      float64
+	Y      float64
+	Width  float64
+	Height float64
+}
+
+//Pointfloat 鍧愭爣鐐�
+type Pointfloat struct {
+	X float64 `json:"x"`
+	Y float64 `json:"y"`
+}
+
 //PintIsInPolygon 鍒ゆ柇鐐规槸鍚﹀湪澶氳竟褰㈠唴閮�
 //point涓鸿鍒ゆ柇鐨勫潗鏍囩偣
 //polygon鏄杈瑰舰鍚勭偣鏁扮粍
-func pintIsInPolygon(point structure.Pointfloat, polygon []structure.Point, widthScale float64, heightScale float64) bool {
+func PintIsInPolygon(point structure.Pointfloat, polygon []structure.Point, widthScale float64, heightScale float64) bool {
 	var nCross int = 0
 	for i := 0; i < len(polygon); i++ {
 
@@ -53,11 +67,7 @@
 }
 
 //GetLocation 灏嗕竴涓粰瀹氳捣濮嬪潗鏍囷紝瀹藉害闀垮害鐨勭煩褰㈠尯鍩熷潎鍒嗕负n鏂逛唤骞惰繑鍥炰腑蹇冨潗鏍囷紙n涓哄崟杈瑰钩鍒嗘暟鍊硷級鍜岄潰绉�
-<<<<<<< HEAD
-func getLocation(rect structure.Rect, n int) ([]structure.Pointfloat, float64) {
-=======
-func getLocation(rect structure.Rect, n int) ([]Pointfloat, float64) {
->>>>>>> master
+func GetLocation(rect structure.Rect, n int) ([]structure.Pointfloat, float64) {
 	xArr := make([]float64, n) // 鐢ㄥ垏鐗囦笉鐢ㄦ暟缁勶紝鏁扮粍涓嶈兘鐢ㄥ彉閲忓畾涔夐暱搴�
 	yArr := make([]float64, n)
 	pointArr := make([]structure.Pointfloat, 0, n*n)
@@ -76,7 +86,7 @@
 }
 
 //ComputePolygonArea 璁$畻浠绘剰澶氳竟褰㈤潰绉�
-func computePolygonArea(polygon []structure.Point) float64 {
+func ComputePolygonArea(polygon []structure.Point) float64 {
 	pointNum := len(polygon)
 	var s float64 = 0
 	if pointNum < 3 {
@@ -90,22 +100,18 @@
 }
 
 //PgsInterPercent calculate percent of two polygon intersection  璁$畻涓や釜澶氳竟褰㈢殑閲嶅彔鍗犳瘮
-<<<<<<< HEAD
 func PgsInterPercent(pgpts []structure.Point, box structure.Rect, widthScale float64, heightScale float64) (percent float64) {
-=======
-func PgsInterPercent(pgpts []Point, box structure.Rect, widthScale float64, heightScale float64) (percent float64) {
->>>>>>> master
 
-	areapts, areaBox := getLocation(box, 10)
+	areapts, areaBox := GetLocation(box, 10)
 	var count = 0
 	for _, pts := range areapts {
-		if pintIsInPolygon(pts, pgpts, widthScale, heightScale) {
+		if PintIsInPolygon(pts, pgpts, widthScale, heightScale) {
 			count++
 		}
 	}
 	perInterBox := float64(count) / float64(len(areapts)) // 閲嶅悎闈㈢Н鍗犵煩褰㈢殑姣斾緥
 	areaInter := perInterBox * areaBox
-	areaPg := computePolygonArea(pgpts)
+	areaPg := ComputePolygonArea(pgpts)
 	perInterPg := areaInter / areaPg // 閲嶅悎闈㈢Н鍗犲杈瑰舰鍖哄煙鐨勬瘮渚�
 	// 鍝釜鍗犵殑姣斾緥澶ф寜鍝釜璁$畻
 	if perInterBox > perInterPg {

--
Gitblit v1.8.0