From 63645d248c765244488cd34dbc1bb6528ca6b7c7 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期二, 05 九月 2023 09:58:13 +0800 Subject: [PATCH] 修复编译 --- version-control/test/main.go | 262 ++++++++++++++++++++++++++-------------------------- 1 files changed, 131 insertions(+), 131 deletions(-) diff --git a/version-control/test/main.go b/version-control/test/main.go index be37bd2..87788b7 100644 --- a/version-control/test/main.go +++ b/version-control/test/main.go @@ -1,131 +1,131 @@ -package main - -import ( - "fmt" - "math" -) - -type ProgramsInfo struct { - Id string - CreatedAt string - UpdatedAt string - Name string - Desc string - Type string - Arch string - LatestVersion string - LatestPackage string -} - -var Data = `{"code":200,"data":[],"msg":"璇锋眰澶勭悊鎴愬姛","success":true}` - -type Point struct { - Log float64 //缁忓害X - Lat float64 //缁村害Y -} - -func main() { - ps := []Point{{116.3325833222656, 40.04070204153866}, {116.41635407421873, 40.042804758324685}, {116.42184723828123, 39.98495642053631}, {116.3380764863281, 39.98179964655109}} - n1 := Point{116.36966217968748, 40.01651613780475} - //n1 := Point{116.3710354707031,39.92916527606944} - fmt.Print(IsPointInPolygon(n1, ps)) - -} - -func IsPointInPolygon(point Point, points []Point) bool { - N := len(points) - boundOrVertex := true //鐐瑰湪澶氳竟褰㈤《鐐规垨鑰呰竟涓婏紝绠椾綔澶氳竟褰㈠唴 - intersectCount := 0 - precision := 2e-10 //娴偣绫诲瀷璁$畻鏃跺�欎笌0姣旇緝鏃跺�欑殑瀹瑰樊 - var p1, p2 Point - p := point //褰撳墠鐐� - p1 = points[0] - for i := 0; i <= N; i++ { - if p == p1 { - return boundOrVertex - } - - p2 = points[i%N] - if p.Log < math.Min(p1.Log, p2.Log) || p.Log > math.Max(p1.Log, p2.Log) { - p1 = p2 - continue - } - if p.Log > math.Min(p1.Log, p2.Log) && p.Log < math.Max(p1.Log, p2.Log) { - if p.Lat <= math.Max(p1.Lat, p2.Lat) { - - if p1.Log == p2.Log && p.Lat >= math.Min(p1.Lat, p2.Lat) { - return boundOrVertex - } - - if p1.Lat == p2.Lat { - if p1.Lat == p.Lat { - return boundOrVertex - } else { - intersectCount++ - } - } else { - xinters := (p.Log-p1.Log)*(p2.Lat-p1.Lat)/(p2.Log-p1.Log) + p1.Lat - if math.Abs(p.Lat-xinters) < precision { - return boundOrVertex - } - - if p.Lat < xinters { - intersectCount++ - } - } - } - - } else { - if p.Log == p2.Log && p.Lat <= p2.Lat { - p3 := points[(i+1)%N] - if p.Log >= math.Min(p1.Log, p3.Log) && p.Log <= math.Max(p1.Log, p3.Log) { - intersectCount++ - } else { - intersectCount += 2 - } - } - } - p1 = p2 - } - - if intersectCount%2 == 0 { //鍋舵暟鍦ㄥ杈瑰舰鍐� - return false - } else { //濂囨暟鍦ㄥ杈瑰舰澶� - return true - } -} - -//func IsPointInPolygon(point Point, points []Point) bool { -// var iSum, iCount, iIndex int32 -// var dLog1, dLog2, dLat1, dLat2, dLog float64 -// if len(points) < 3 { -// return false -// } -// iCount = int32(len(points)) -// for iIndex = 0; iIndex < iCount; iIndex++ { -// dLog1 = points[iIndex].Log -// dLat1 = points[iIndex].Lat -// if iIndex == iCount-1 { -// dLog2 = points[0].Log -// dLat2 = points[0].Lat -// } else { -// dLog2 = points[iIndex+1].Log -// dLat2 = points[iIndex+1].Lat -// } -// //鍒ゆ柇A鐐规槸鍚﹀湪杈圭殑涓ょ鐐圭殑姘村钩骞宠绾夸箣闂达紝鍦ㄥ垯鍙兘鏈変氦鐐癸紝寮�濮嬪垽鏂氦鐐癸紝寮�濮嬪垽鏂氦鐐规槸鍚﹀湪宸﹀皠绾夸笂 -// if ((point.Lat >= dLat1) && (point.Lat < dLat2)) || ((point.Lat >= dLat2) && (point.Lat < dLat1)) { -// if math.Abs(dLat1-dLat2) > 0 { -// //寰楀埌A鐐瑰悜宸﹀皠绾夸笌杈圭殑浜ょ偣鐨剎鍧愭爣 -// dLog = dLog - ((dLog1-dLog2)*(dLat1-point.Lat))/(dLat1-dLat2) -// //濡傛灉浜ょ偣鍦ˋ鐐瑰乏渚э紙璇存槑鏄乏灏勭嚎涓庤竟鐨勪氦鐐癸級锛屽垯灏勭嚎涓庤竟鐨勫叏閮ㄤ氦鐐规暟鍔犱竴 -// if dLog < point.Log { -// iSum++ -// } -// } -// } -// } -// if (iSum % 2) != 0 { -// return true -// } -// return false -//} +package main + +import ( + "fmt" + "math" +) + +type ProgramsInfo struct { + Id string + CreatedAt string + UpdatedAt string + Name string + Desc string + Type string + Arch string + LatestVersion string + LatestPackage string +} + +var Data = `{"code":200,"data":[],"msg":"璇锋眰澶勭悊鎴愬姛","success":true}` + +type Point struct { + Log float64 //缁忓害X + Lat float64 //缁村害Y +} + +func main() { + ps := []Point{{116.3325833222656, 40.04070204153866}, {116.41635407421873, 40.042804758324685}, {116.42184723828123, 39.98495642053631}, {116.3380764863281, 39.98179964655109}} + n1 := Point{116.36966217968748, 40.01651613780475} + //n1 := Point{116.3710354707031,39.92916527606944} + fmt.Print(IsPointInPolygon(n1, ps)) + +} + +func IsPointInPolygon(point Point, points []Point) bool { + N := len(points) + boundOrVertex := true //鐐瑰湪澶氳竟褰㈤《鐐规垨鑰呰竟涓婏紝绠椾綔澶氳竟褰㈠唴 + intersectCount := 0 + precision := 2e-10 //娴偣绫诲瀷璁$畻鏃跺�欎笌0姣旇緝鏃跺�欑殑瀹瑰樊 + var p1, p2 Point + p := point //褰撳墠鐐� + p1 = points[0] + for i := 0; i <= N; i++ { + if p == p1 { + return boundOrVertex + } + + p2 = points[i%N] + if p.Log < math.Min(p1.Log, p2.Log) || p.Log > math.Max(p1.Log, p2.Log) { + p1 = p2 + continue + } + if p.Log > math.Min(p1.Log, p2.Log) && p.Log < math.Max(p1.Log, p2.Log) { + if p.Lat <= math.Max(p1.Lat, p2.Lat) { + + if p1.Log == p2.Log && p.Lat >= math.Min(p1.Lat, p2.Lat) { + return boundOrVertex + } + + if p1.Lat == p2.Lat { + if p1.Lat == p.Lat { + return boundOrVertex + } else { + intersectCount++ + } + } else { + xinters := (p.Log-p1.Log)*(p2.Lat-p1.Lat)/(p2.Log-p1.Log) + p1.Lat + if math.Abs(p.Lat-xinters) < precision { + return boundOrVertex + } + + if p.Lat < xinters { + intersectCount++ + } + } + } + + } else { + if p.Log == p2.Log && p.Lat <= p2.Lat { + p3 := points[(i+1)%N] + if p.Log >= math.Min(p1.Log, p3.Log) && p.Log <= math.Max(p1.Log, p3.Log) { + intersectCount++ + } else { + intersectCount += 2 + } + } + } + p1 = p2 + } + + if intersectCount%2 == 0 { //鍋舵暟鍦ㄥ杈瑰舰鍐� + return false + } else { //濂囨暟鍦ㄥ杈瑰舰澶� + return true + } +} + +//func IsPointInPolygon(point Point, points []Point) bool { +// var iSum, iCount, iIndex int32 +// var dLog1, dLog2, dLat1, dLat2, dLog float64 +// if len(points) < 3 { +// return false +// } +// iCount = int32(len(points)) +// for iIndex = 0; iIndex < iCount; iIndex++ { +// dLog1 = points[iIndex].Log +// dLat1 = points[iIndex].Lat +// if iIndex == iCount-1 { +// dLog2 = points[0].Log +// dLat2 = points[0].Lat +// } else { +// dLog2 = points[iIndex+1].Log +// dLat2 = points[iIndex+1].Lat +// } +// //鍒ゆ柇A鐐规槸鍚﹀湪杈圭殑涓ょ鐐圭殑姘村钩骞宠绾夸箣闂达紝鍦ㄥ垯鍙兘鏈変氦鐐癸紝寮�濮嬪垽鏂氦鐐癸紝寮�濮嬪垽鏂氦鐐规槸鍚﹀湪宸﹀皠绾夸笂 +// if ((point.Lat >= dLat1) && (point.Lat < dLat2)) || ((point.Lat >= dLat2) && (point.Lat < dLat1)) { +// if math.Abs(dLat1-dLat2) > 0 { +// //寰楀埌A鐐瑰悜宸﹀皠绾夸笌杈圭殑浜ょ偣鐨剎鍧愭爣 +// dLog = dLog - ((dLog1-dLog2)*(dLat1-point.Lat))/(dLat1-dLat2) +// //濡傛灉浜ょ偣鍦ˋ鐐瑰乏渚э紙璇存槑鏄乏灏勭嚎涓庤竟鐨勪氦鐐癸級锛屽垯灏勭嚎涓庤竟鐨勫叏閮ㄤ氦鐐规暟鍔犱竴 +// if dLog < point.Log { +// iSum++ +// } +// } +// } +// } +// if (iSum % 2) != 0 { +// return true +// } +// return false +//} -- Gitblit v1.8.0