fix
panlei
2019-11-05 d89b8202c5d921cad8b68ea4dd482ffd6d48afac
ruleserver/geoPolygon.go
@@ -2,6 +2,7 @@
import (
   "math"
   "ruleprocess/structure"
)
func min(num1 float64, num2 float64) float64 {
@@ -72,7 +73,7 @@
}
//GetLocation 将一个给定起始坐标,宽度长度的矩形区域均分为n方份并返回中心坐标(n为单边平分数值)和面积
func getLocation(rect Rect, n int) ([]Pointfloat, float64) {
func getLocation(rect structure.Rect, n int) ([]Pointfloat, float64) {
   xArr := make([]float64, n) // 用切片不用数组,数组不能用变量定义长度
   yArr := make([]float64, n)
   pointArr := make([]Pointfloat, 0, n*n)
@@ -105,7 +106,7 @@
}
//PgsInterPercent calculate percent of two polygon intersection  计算两个多边形的重叠占比
func PgsInterPercent(pgpts []Point, box Rect, widthScale float64, heightScale float64) (percent float64) {
func PgsInterPercent(pgpts []Point, box structure.Rect, widthScale float64, heightScale float64) (percent float64) {
   areapts, areaBox := getLocation(box, 10)
   var count = 0
@@ -120,7 +121,7 @@
   perInterPg := areaInter / areaPg // 重合面积占多边形区域的比例
   // 哪个占的比例大按哪个计算
   if perInterBox > perInterPg {
      return perInterBox
      return (perInterBox*100)
   }
   return perInterPg*100
   return (perInterPg*100)
}