Commit 5d912777 authored by M. Rehan Abbasi's avatar M. Rehan Abbasi
Browse files

fix comma typo in traffic manager query and add input valdiation

parent 5a6f877e
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -863,7 +863,7 @@ func (tm *TrafficMgr) GetPoaCategory(longitude float32, latitude float32) (categ

	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 + ");"
	dbQuery := "SELECT category FROM " + GridTable + " WHERE ST_Contains(" + GridTable + ".grid, 'SRID=4326;POINT" + coordinates + "');"

	var rows *sql.Rows
	rows, err = tm.db.Query(dbQuery)
@@ -892,6 +892,17 @@ func (tm *TrafficMgr) GetPoaCategory(longitude float32, latitude float32) (categ

// PopulatePoaLoad - Populate the Traffic Load table
func (tm *TrafficMgr) PopulatePoaLoad(poaNameList []string, gpsCoordinates [][]float32) (err error) {
	// Validate input
	if poaNameList == nil {
		err = errors.New("Missing POA Name List")
		return err
	}

	if gpsCoordinates == nil {
		err = errors.New("Missing GPS coordinates")
		return err
	}

	for i, poaName := range poaNameList {
		poaLongitude := gpsCoordinates[i][0]
		poaLatitude := gpsCoordinates[i][1]