Loading go-apps/meep-vis/sbi/vis-sbi.go +65 −36 Original line number Diff line number Diff line Loading @@ -17,9 +17,14 @@ package sbi import ( "os" "strconv" "strings" "sync" // "time" dataModel "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model" gc "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-gis-cache" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" met "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-metrics" Loading Loading @@ -137,6 +142,18 @@ func Init(cfg SbiCfg) (err error) { } log.Info("Connected to GIS Cache") // Get prediction model support var predictionModelSupported bool = false predictionModelSupportedEnv := strings.TrimSpace(os.Getenv("MEEP_PREDICT_MODEL_SUPPORTED")) if predictionModelSupportedEnv != "" { value, err := strconv.ParseBool(predictionModelSupportedEnv) if err == nil { predictionModelSupported = value } } log.Info("MEEP_PREDICT_MODEL_SUPPORTED: ", predictionModelSupported) if predictionModelSupported { // Connect to VIS Traffic Manager sbi.trafficMgr, err = tm.NewTrafficMgr(sbi.moduleName, sbi.sandboxName, postgisUser, postgisPwd, "", "") if err != nil { Loading @@ -155,7 +172,12 @@ func Init(cfg SbiCfg) (err error) { return err } log.Info("Created new VIS DB tables") } // Initialize service processActiveScenarioUpdate() if predictionModelSupported { // Populate VIS DB Grid Map Table err = sbi.trafficMgr.PopulateGridMapTable() if err != nil { Loading @@ -172,9 +194,6 @@ func Init(cfg SbiCfg) (err error) { } log.Info("Populated VIS DB categories table") // Initialize service processActiveScenarioUpdate() // Populate VIS DB Traffic Load Table err = populatePoaTable() if err != nil { Loading @@ -182,6 +201,7 @@ func Init(cfg SbiCfg) (err error) { return err } log.Info("Populated VIS DB traffic load table") } return nil } Loading Loading @@ -308,7 +328,16 @@ func processActiveScenarioUpdate() { func populatePoaTable() (err error) { poaNameList := sbi.activeModel.GetNodeNames(mod.NodeTypePoa4G, mod.NodeTypePoa5G) err = sbi.trafficMgr.PopulateStaticPoaLoad(poaNameList) var gpsCoordinates [][]float32 for _, poaName := range poaNameList { node := sbi.activeModel.GetNode(poaName) if node != nil { nl := node.(*dataModel.NetworkLocation) location := nl.GeoData.Location.Coordinates gpsCoordinates = append(gpsCoordinates, location) } } err = sbi.trafficMgr.PopulatePoaLoad(poaNameList, gpsCoordinates) if err != nil { log.Error(err.Error()) return err Loading go-packages/meep-vis-traffic-mgr/traffic-mgr.go +51 −44 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import ( "database/sql" _ "embed" "errors" "strconv" "strings" "time" Loading Loading @@ -854,50 +855,56 @@ func (tm *TrafficMgr) PopulateCategoryTable() (err error) { return nil } // PopulateStaticPoaLoad - Populate the Traffic Load table with static data func (tm *TrafficMgr) PopulateStaticPoaLoad(poaNameList []string) (err error) { var poaCategoryMap = map[string]string{ "4g-macro-cell-6": "commercial", "4g-macro-cell-7": "commercial", "5g-small-cell-4": "commercial", "5g-small-cell-5": "commercial", "5g-small-cell-6": "commercial", "5g-small-cell-7": "commercial", "5g-small-cell-10": "commercial", "5g-small-cell-11": "commercial", "5g-small-cell-12": "commercial", "4g-macro-cell-1": "residential", "4g-macro-cell-2": "residential", "4g-macro-cell-3": "residential", "4g-macro-cell-4": "residential", "4g-macro-cell-5": "residential", "4g-macro-cell-8": "residential", "4g-macro-cell-9": "residential", "5g-small-cell-1": "residential", "5g-small-cell-2": "residential", "5g-small-cell-3": "residential", "5g-small-cell-8": "residential", "5g-small-cell-9": "residential", "5g-small-cell-13": "residential", "5g-small-cell-14": "residential", "5g-small-cell-15": "residential", "4g-macro-cell-10": "coastal", "5g-small-cell-16": "coastal", "5g-small-cell-17": "coastal", "5g-small-cell-18": "coastal", "5g-small-cell-19": "coastal", "5g-small-cell-20": "coastal", } for _, poaName := range poaNameList { for poa, category := range poaCategoryMap { if poa == poaName { err = tm.CreatePoaLoad(poaName, category) // GetPoaCategory - Get the category for a PoA func (tm *TrafficMgr) GetPoaCategory(longitude float32, latitude float32) (category string, err error) { if profiling { profilingTimers["GetPoaCategory"] = time.Now() } coordinates := "(" + strconv.FormatFloat(float64(longitude), 'E', -1, 32) + " " + strconv.FormatFloat(float64(latitude), 'E', -1, 32) + ")" dbQuery := "SELECT category FROM " + GridTable + " WHERE ST_Contains(" + GridTable + ".grid" + ", 'SRID=4326;POINT" + coordinates + ");" var rows *sql.Rows rows, err = tm.db.Query(dbQuery) if err != nil { log.Error(err.Error()) return err return "", err } defer rows.Close() category = "" if rows.Next() { err = rows.Scan(&category) if err != nil { log.Error(err.Error()) return category, err } return category, nil } err = rows.Err() if err != nil { log.Error(err) } return category, err } // PopulatePoaLoad - Populate the Traffic Load table func (tm *TrafficMgr) PopulatePoaLoad(poaNameList []string, gpsCoordinates [][]float32) (err error) { for i, poaName := range poaNameList { poaLongitude := gpsCoordinates[i][0] poaLatitude := gpsCoordinates[i][1] category, err := tm.GetPoaCategory(poaLongitude, poaLatitude) if err != nil { log.Error(err.Error()) return err } err = tm.CreatePoaLoad(poaName, category) if err != nil { log.Error(err.Error()) return err } } Loading Loading
go-apps/meep-vis/sbi/vis-sbi.go +65 −36 Original line number Diff line number Diff line Loading @@ -17,9 +17,14 @@ package sbi import ( "os" "strconv" "strings" "sync" // "time" dataModel "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-model" gc "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-gis-cache" log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger" met "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-metrics" Loading Loading @@ -137,6 +142,18 @@ func Init(cfg SbiCfg) (err error) { } log.Info("Connected to GIS Cache") // Get prediction model support var predictionModelSupported bool = false predictionModelSupportedEnv := strings.TrimSpace(os.Getenv("MEEP_PREDICT_MODEL_SUPPORTED")) if predictionModelSupportedEnv != "" { value, err := strconv.ParseBool(predictionModelSupportedEnv) if err == nil { predictionModelSupported = value } } log.Info("MEEP_PREDICT_MODEL_SUPPORTED: ", predictionModelSupported) if predictionModelSupported { // Connect to VIS Traffic Manager sbi.trafficMgr, err = tm.NewTrafficMgr(sbi.moduleName, sbi.sandboxName, postgisUser, postgisPwd, "", "") if err != nil { Loading @@ -155,7 +172,12 @@ func Init(cfg SbiCfg) (err error) { return err } log.Info("Created new VIS DB tables") } // Initialize service processActiveScenarioUpdate() if predictionModelSupported { // Populate VIS DB Grid Map Table err = sbi.trafficMgr.PopulateGridMapTable() if err != nil { Loading @@ -172,9 +194,6 @@ func Init(cfg SbiCfg) (err error) { } log.Info("Populated VIS DB categories table") // Initialize service processActiveScenarioUpdate() // Populate VIS DB Traffic Load Table err = populatePoaTable() if err != nil { Loading @@ -182,6 +201,7 @@ func Init(cfg SbiCfg) (err error) { return err } log.Info("Populated VIS DB traffic load table") } return nil } Loading Loading @@ -308,7 +328,16 @@ func processActiveScenarioUpdate() { func populatePoaTable() (err error) { poaNameList := sbi.activeModel.GetNodeNames(mod.NodeTypePoa4G, mod.NodeTypePoa5G) err = sbi.trafficMgr.PopulateStaticPoaLoad(poaNameList) var gpsCoordinates [][]float32 for _, poaName := range poaNameList { node := sbi.activeModel.GetNode(poaName) if node != nil { nl := node.(*dataModel.NetworkLocation) location := nl.GeoData.Location.Coordinates gpsCoordinates = append(gpsCoordinates, location) } } err = sbi.trafficMgr.PopulatePoaLoad(poaNameList, gpsCoordinates) if err != nil { log.Error(err.Error()) return err Loading
go-packages/meep-vis-traffic-mgr/traffic-mgr.go +51 −44 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import ( "database/sql" _ "embed" "errors" "strconv" "strings" "time" Loading Loading @@ -854,50 +855,56 @@ func (tm *TrafficMgr) PopulateCategoryTable() (err error) { return nil } // PopulateStaticPoaLoad - Populate the Traffic Load table with static data func (tm *TrafficMgr) PopulateStaticPoaLoad(poaNameList []string) (err error) { var poaCategoryMap = map[string]string{ "4g-macro-cell-6": "commercial", "4g-macro-cell-7": "commercial", "5g-small-cell-4": "commercial", "5g-small-cell-5": "commercial", "5g-small-cell-6": "commercial", "5g-small-cell-7": "commercial", "5g-small-cell-10": "commercial", "5g-small-cell-11": "commercial", "5g-small-cell-12": "commercial", "4g-macro-cell-1": "residential", "4g-macro-cell-2": "residential", "4g-macro-cell-3": "residential", "4g-macro-cell-4": "residential", "4g-macro-cell-5": "residential", "4g-macro-cell-8": "residential", "4g-macro-cell-9": "residential", "5g-small-cell-1": "residential", "5g-small-cell-2": "residential", "5g-small-cell-3": "residential", "5g-small-cell-8": "residential", "5g-small-cell-9": "residential", "5g-small-cell-13": "residential", "5g-small-cell-14": "residential", "5g-small-cell-15": "residential", "4g-macro-cell-10": "coastal", "5g-small-cell-16": "coastal", "5g-small-cell-17": "coastal", "5g-small-cell-18": "coastal", "5g-small-cell-19": "coastal", "5g-small-cell-20": "coastal", } for _, poaName := range poaNameList { for poa, category := range poaCategoryMap { if poa == poaName { err = tm.CreatePoaLoad(poaName, category) // GetPoaCategory - Get the category for a PoA func (tm *TrafficMgr) GetPoaCategory(longitude float32, latitude float32) (category string, err error) { if profiling { profilingTimers["GetPoaCategory"] = time.Now() } coordinates := "(" + strconv.FormatFloat(float64(longitude), 'E', -1, 32) + " " + strconv.FormatFloat(float64(latitude), 'E', -1, 32) + ")" dbQuery := "SELECT category FROM " + GridTable + " WHERE ST_Contains(" + GridTable + ".grid" + ", 'SRID=4326;POINT" + coordinates + ");" var rows *sql.Rows rows, err = tm.db.Query(dbQuery) if err != nil { log.Error(err.Error()) return err return "", err } defer rows.Close() category = "" if rows.Next() { err = rows.Scan(&category) if err != nil { log.Error(err.Error()) return category, err } return category, nil } err = rows.Err() if err != nil { log.Error(err) } return category, err } // PopulatePoaLoad - Populate the Traffic Load table func (tm *TrafficMgr) PopulatePoaLoad(poaNameList []string, gpsCoordinates [][]float32) (err error) { for i, poaName := range poaNameList { poaLongitude := gpsCoordinates[i][0] poaLatitude := gpsCoordinates[i][1] category, err := tm.GetPoaCategory(poaLongitude, poaLatitude) if err != nil { log.Error(err.Error()) return err } err = tm.CreatePoaLoad(poaName, category) if err != nil { log.Error(err.Error()) return err } } Loading