Commit 904f7355 authored by M. Rehan Abbasi's avatar M. Rehan Abbasi
Browse files

use proper response input for /geodata/cellularPower endpoint

parent 6308d839
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -1632,7 +1632,7 @@ func geUpdateGeoDataByName(w http.ResponseWriter, r *http.Request) {

func geGetGeoDataPowerValues(w http.ResponseWriter, r *http.Request) {
	// Retrieve coordinates to work with from request body
	var coordinates []am.Coordinate
	var coordinates CoordinatePowerList
	if r.Body == nil {
		err := errors.New("Request body is missing")
		log.Error(err.Error())
@@ -1654,7 +1654,15 @@ func geGetGeoDataPowerValues(w http.ResponseWriter, r *http.Request) {
		return
	}

	coordinatesPower, err := ge.assetMgr.GetPowerValuesForCoordinates(coordinates)
	var geocoordinates []am.Coordinate
	for _, geocoordinate := range coordinates.CoordinatesPower {
		geocoordinates = append(geocoordinates, am.Coordinate{
			Latitude:  geocoordinate.Latitude,
			Longitude: geocoordinate.Longitude,
		})
	}

	coordinatesPower, err := ge.assetMgr.GetPowerValuesForCoordinates(geocoordinates)
	if err != nil {
		log.Error(err.Error())
		http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -1680,11 +1688,12 @@ func geGetGeoDataPowerValues(w http.ResponseWriter, r *http.Request) {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	jsonResponseStr := string(jsonResponse)

	// Send response
	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	w.WriteHeader(http.StatusOK)
	fmt.Fprint(w, jsonResponse)
	fmt.Fprint(w, jsonResponseStr)
}

func (ge *GisEngine) StartSnapshotThread() error {