Commit 6308d839 authored by M. Rehan Abbasi's avatar M. Rehan Abbasi
Browse files

make RSRQ/RSRP uint8 in response of /geodata/cellularPower endpoint

parent 2d183484
Loading
Loading
Loading
Loading
+69 −39
Original line number Diff line number Diff line
@@ -163,33 +163,6 @@ paths:
            $ref: "#/definitions/GeoDataAssetList"
        "500":
          description: "Internal server error"
  /geodata/cellularPower:
    post:
      tags:
      - "Geospatial Data"
      summary: "Returns RSRQ and RSRP values for a list of coordinates"
      description: "Get geospatial data for the given asset and if it is within range\
        \ of another asset or geospatial coordinates"
      operationId: "getGeoDataPowerValues"
      produces:
      - "application/json"
      parameters:
      - in: "body"
        name: "coordinates"
        description: "List of geo coordinates "
        required: true
        schema:
          $ref: "#/definitions/Coordinates"
        x-exportParamName: "Coordinates"
      responses:
        "200":
          description: "OK"
          schema:
            $ref: "#/definitions/CoordinatesPower"
        "404":
          description: "Not found"
        "500":
          description: "Internal server error"
  /geodata/{assetName}:
    get:
      tags:
@@ -343,6 +316,33 @@ paths:
          description: "Not found"
        "500":
          description: "Internal server error"
  /geodata/cellularPower:
    post:
      tags:
      - "Geospatial Data"
      summary: "Get RSRQ and RSRP values for a list of coordinates"
      description: "Get geospatial data for the given asset and if it is within range\
        \ of another asset or geospatial coordinates"
      operationId: "getGeoDataPowerValues"
      produces:
      - "application/json"
      parameters:
      - in: "body"
        name: "coordinates"
        description: "List of geo coordinates"
        required: true
        schema:
          $ref: "#/definitions/GeoCoordinateList"
        x-exportParamName: "Coordinates"
      responses:
        "200":
          description: "OK"
          schema:
            $ref: "#/definitions/CoordinatePowerList"
        "404":
          description: "Not found"
        "500":
          description: "Internal server error"
definitions:
  AutomationStateList:
    type: "object"
@@ -377,18 +377,20 @@ definitions:
    example:
      active: true
      type: "MOBILITY"
  Coordinates:
    type: "array"
    items:
      $ref: "#/definitions/TargetPoint"
  CoordinatePowerList:
    type: "object"
    properties:
      CoordinatesPower:
        type: "array"
        items:
          $ref: "#/definitions/CoordinatePower"
    description: "List of geo coordinates with RSRQ/RSRP values"
    example: {}
  CoordinatePower:
    required:
    - "latitude"
    - "longitude"
    - "poaName"
    - "rsrp"
    - "rsrq"
    properties:
@@ -401,20 +403,48 @@ definitions:
        format: "float"
        description: "Longitude of a second element for query purpose."
      rsrq:
        type: "number"
        format: "float"
        type: "integer"
        format: "uint8"
        description: "Reference Signal Received Quality as defined in ETSI TS 136\
          \ 214."
      rsrp:
        type: "number"
        format: "float"
        type: "integer"
        format: "uint8"
        description: "Reference Signal Received Power as defined in ETSI TS 136 214."
      poaName:
        type: "string"
        description: "Name of the POA for which RSRP/RSRQ values are calculated."
    description: "Coordinates with their power values."
    example:
      latitude: 0.8008282
      longitude: 6.0274563
      rsrq: -2
      rsrp: 40
      poaName: "5G-macro-cell-15"
  GeoCoordinateList:
    type: "object"
    properties:
      GeoCoordinates:
        type: "array"
        items:
          $ref: "#/definitions/GeoCoordinate"
    description: "List of geo-coordinates"
    example: {}
  GeoCoordinate:
    type: "object"
    properties:
      latitude:
        type: "number"
        format: "float"
        description: "Latitude of a second element for query purpose."
      longitude:
        type: "number"
        format: "float"
        description: "Longitude of a second element for query purpose."
    description: "Geo-coordinates for cellular power."
    example:
      latitude: 0.8008282
      longitude: 6.0274563
  TargetPoint:
    type: "object"
    properties:
+19 −10
Original line number Diff line number Diff line
@@ -1661,21 +1661,30 @@ func geGetGeoDataPowerValues(w http.ResponseWriter, r *http.Request) {
		return
	}

	jsonResponse := convertCoodinatesPowerToJson(&coordinatesPower)

	// Send response
	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	w.WriteHeader(http.StatusOK)
	fmt.Fprint(w, jsonResponse)
	var intCoordinatesPower CoordinatePowerList
	for _, coordinatePower := range coordinatesPower {
		var intCoordinatePower = CoordinatePower{
			Latitude:  coordinatePower.Latitude,
			Longitude: coordinatePower.Longitude,
			Rsrq:      uint8(coordinatePower.Rsrq),
			Rsrp:      uint8(coordinatePower.Rsrp),
			PoaName:   coordinatePower.PoaName,
		}
		intCoordinatesPower.CoordinatesPower = append(intCoordinatesPower.CoordinatesPower, intCoordinatePower)
	}

func convertCoodinatesPowerToJson(coordinatesPower *[]am.CoordinatePowerValue) string {
	jsonInfo, err := json.Marshal(*coordinatesPower)
	// Format response
	jsonResponse, err := json.Marshal(&intCoordinatesPower)
	if err != nil {
		log.Error(err.Error())
		return ""
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	return string(jsonInfo)

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

func (ge *GisEngine) StartSnapshotThread() error {
+5 −2
Original line number Diff line number Diff line
@@ -34,8 +34,11 @@ type CoordinatePower struct {
	Longitude float32 `json:"longitude"`

	// Reference Signal Received Quality as defined in ETSI TS 136 214.
	Rsrq float32 `json:"rsrq"`
	Rsrq uint8 `json:"rsrq"`

	// Reference Signal Received Power as defined in ETSI TS 136 214.
	Rsrp float32 `json:"rsrp"`
	Rsrp uint8 `json:"rsrp"`

	// Name of the POA for which RSRP/RSRQ values are calculated.
	PoaName string `json:"poaName"`
}
+4 −1
Original line number Diff line number Diff line
@@ -24,5 +24,8 @@

package server

type CoordinatesPower struct {
// List of geo coordinates with RSRQ/RSRP values
type CoordinatePowerList struct {

	CoordinatesPower []CoordinatePower `json:"CoordinatesPower,omitempty"`
}
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2020  InterDigital Communications, Inc
 *
 * Licensed under the Apache License, Version 2.0 (the \"License\");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an \"AS IS\" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * AdvantEDGE GIS Engine REST API
 *
 * This API allows to control geo-spatial behavior and simulation. <p>**Micro-service**<br>[meep-gis-engine](https://github.com/InterDigitalInc/AdvantEDGE/tree/master/go-apps/meep-gis-engine) <p>**Type & Usage**<br>Platform runtime interface to control geo-spatial behavior and simulation <p>**Details**<br>API details available at _your-AdvantEDGE-ip-address/api_
 *
 * API version: 1.0.0
 * Contact: AdvantEDGE@InterDigital.com
 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
 */

package server

// Geo-coordinates for cellular power.
type GeoCoordinate struct {

	// Latitude of a second element for query purpose.
	Latitude float32 `json:"latitude,omitempty"`

	// Longitude of a second element for query purpose.
	Longitude float32 `json:"longitude,omitempty"`
}
Loading