| | |
| | | //PintIsInPolygon 判断点是否在多边形内部 |
| | | //point为要判断的坐标点 |
| | | //polygon是多边形各点数组 |
| | | func pintIsInPolygon(point Pointfloat, polygon []Point, widthScale float64, heightScale float64) bool { |
| | | func pintIsInPolygon(point structure.Pointfloat, polygon []Point, widthScale float64, heightScale float64) bool { |
| | | var nCross int = 0 |
| | | for i := 0; i < len(polygon); i++ { |
| | | |
| | |
| | | func getLocation(rect structure.Rect, n int) ([]structure.Pointfloat, float64) { |
| | | xArr := make([]float64, n) // 用切片不用数组,数组不能用变量定义长度 |
| | | yArr := make([]float64, n) |
| | | pointArr := make([]Pointfloat, 0, n*n) |
| | | pointArr := make([]structure.Pointfloat, 0, n*n) |
| | | for i := 0; i < n; i++ { |
| | | xArr[i] = rect.X + (rect.Width/float64(2*n))*float64(2*i+1) |
| | | yArr[i] = rect.Y + (rect.Height/float64(2*n))*float64(2*i+1) |
| | | } |
| | | for i := 0; i < n; i++ { |
| | | for j := 0; j < n; j++ { |
| | | point := Pointfloat{X: xArr[i], Y: yArr[j]} |
| | | point := structure.Pointfloat{X: xArr[i], Y: yArr[j]} |
| | | pointArr = append(pointArr, point) |
| | | } |
| | | } |
| | |
| | | |
| | | import ( |
| | | "basic.com/pubsub/protomsg.git" |
| | | "basic.com/valib/logger.git" |
| | | "github.com/knetic/govaluate" |
| | | "plugin" |
| | | "ruleprocess/cache" |
| | | "ruleprocess/structure" |
| | | "ruleprocess/logger" |
| | | "ruleprocess/structure" |
| | | "sort" |
| | | "strconv" |
| | | "strings" |
| | | "sync" |
| | | "time" |
| | | |
| | | "basic.com/pubsub/protomsg.git" |
| | | "github.com/knetic/govaluate" |
| | | ) |
| | | |
| | | |
| | |
| | | |
| | | // 如果有持续时间条件维护开启一个定时器 |
| | | func duration(rule *protomsg.Rule, groupId string, am *structure.AreaMap, args *structure.SdkDatas, message *protomsg.SdkMessage) string{ |
| | | cacheId := "" |
| | | if rule.PolygonId == am.AreaId { // 首先规则所对应的区域id要跟区域数据的id对的上 配置的算法要对的上 |
| | | if rule.SdkArgAlias == "duration" { // |
| | | //logger.Info("当前小规则是:---------", rule) |