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

add /geodata/cellularPower endpoint in GIS engine with handler function

parent f42112fe
Loading
Loading
Loading
Loading
+84 −53
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ paths:
      - "application/json"
      parameters: []
      responses:
        200:
        "200":
          description: "OK"
          schema:
            $ref: "#/definitions/AutomationStateList"
@@ -65,11 +65,11 @@ paths:
        - "NETWORK-CHARACTERISTICS-UPDATE"
        x-exportParamName: "Type_"
      responses:
        200:
        "200":
          description: "OK"
          schema:
            $ref: "#/definitions/AutomationState"
        500:
        "500":
          description: "Internal server error"
    post:
      tags:
@@ -105,9 +105,9 @@ paths:
        type: "boolean"
        x-exportParamName: "Run"
      responses:
        200:
        "200":
          description: "OK"
        500:
        "500":
          description: "Internal server error"
  /geodata:
    get:
@@ -157,11 +157,38 @@ paths:
        x-exportParamName: "ExcludePath"
        x-optionalDataType: "String"
      responses:
        200:
        "200":
          description: "OK"
          schema:
            $ref: "#/definitions/GeoDataAssetList"
        500:
        "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: "postGeoDataPowerValues"
      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:
@@ -190,13 +217,13 @@ paths:
        x-exportParamName: "ExcludePath"
        x-optionalDataType: "String"
      responses:
        200:
        "200":
          description: "OK"
          schema:
            $ref: "#/definitions/GeoDataAsset"
        404:
        "404":
          description: "Not found"
        500:
        "500":
          description: "Internal server error"
    post:
      tags:
@@ -221,11 +248,11 @@ paths:
          $ref: "#/definitions/GeoDataAsset"
        x-exportParamName: "GeoData"
      responses:
        200:
        "200":
          description: "OK"
        201:
        "201":
          description: "Created"
        500:
        "500":
          description: "Internal server error"
    delete:
      tags:
@@ -243,11 +270,11 @@ paths:
        type: "string"
        x-exportParamName: "AssetName"
      responses:
        200:
        "200":
          description: "OK"
        404:
        "404":
          description: "Not found"
        500:
        "500":
          description: "Internal server error"
  /geodata/{assetName}/distanceTo:
    post:
@@ -274,47 +301,13 @@ paths:
          $ref: "#/definitions/TargetPoint"
        x-exportParamName: "TargetPoint"
      responses:
        200:
        "200":
          description: "OK"
          schema:
            $ref: "#/definitions/Distance"
        404:
        "404":
          description: "Not found"
        500:
          description: "Internal server error"
  /geodata/{assetName}/withinRange:
    post:
      tags:
      - "Geospatial Data"
      summary: "Returns if a geospatial data points is within a specified distance\
        \ from a location"
      description: "Get geospatial data for the given asset and if it is within range\
        \ of another asset or geospatial coordinates"
      operationId: "getWithinRangeByName"
      produces:
      - "application/json"
      parameters:
      - name: "assetName"
        in: "path"
        description: "Name of geospatial asset"
        required: true
        type: "string"
        x-exportParamName: "AssetName"
      - in: "body"
        name: "targetRange"
        description: "Parameters of geospatial assets"
        required: true
        schema:
          $ref: "#/definitions/TargetRange"
        x-exportParamName: "TargetRange"
      responses:
        200:
          description: "OK"
          schema:
            $ref: "#/definitions/WithinRange"
        404:
          description: "Not found"
        500:
        "500":
          description: "Internal server error"
definitions:
  AutomationStateList:
@@ -350,6 +343,44 @@ definitions:
    example:
      active: true
      type: "MOBILITY"
  Coordinates:
    type: "array"
    items:
      $ref: "#/definitions/TargetPoint"
  CoordinatesPower:
    type: "array"
    items:
      $ref: "#/definitions/CoordinatePower"
  CoordinatePower:
    required:
    - "latitude"
    - "longitude"
    - "rsrp"
    - "rsrq"
    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."
      rsrq:
        type: "number"
        format: "float"
        description: "Reference Signal Received Quality as defined in ETSI TS 136\
          \ 214."
      rsrp:
        type: "number"
        format: "float"
        description: "Reference Signal Received Power as defined in ETSI TS 136 214."
    description: "Coordinates with their power values."
    example:
      latitude: 0.8008282
      longitude: 6.0274563
      rsrq: -2
      rsrp: 40
  TargetPoint:
    type: "object"
    properties:
+4 −0
Original line number Diff line number Diff line
@@ -48,6 +48,10 @@ func GetWithinRangeByName(w http.ResponseWriter, r *http.Request) {
	geGetWithinRangeGeoDataByName(w, r)
}

func PostGeoDataPowerValues(w http.ResponseWriter, r *http.Request) {
	gePostGeoDataPowerValues(w, r)
}

func UpdateGeoDataByName(w http.ResponseWriter, r *http.Request) {
	geUpdateGeoDataByName(w, r)
}
+53 −0
Original line number Diff line number Diff line
@@ -1630,6 +1630,59 @@ func geUpdateGeoDataByName(w http.ResponseWriter, r *http.Request) {
	w.WriteHeader(http.StatusOK)
}

func gePostGeoDataPowerValues(w http.ResponseWriter, r *http.Request) {
	// Retrieve coordinates to work with from request body
	var coordinates Coordinates
	if r.Body == nil {
		err := errors.New("Request body is missing")
		log.Error(err.Error())
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
	decoder := json.NewDecoder(r.Body)
	err := decoder.Decode(&coordinates)
	if err != nil {
		log.Error(err.Error())
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	var amCoordinates []am.Coordinate
	jsonString, _ := json.Marshal(coordinates)
	json.Unmarshal([]byte(jsonString), &amCoordinates)

	// Make sure scenario is active
	if ge.activeModel.GetScenarioName() == "" {
		err := errors.New("No active scenario")
		log.Error(err.Error())
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	coordinatesPower, err := ge.assetMgr.GetPowerValuesForCoordinates(amCoordinates)
	if err != nil {
		log.Error(err.Error())
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	jsonResponse := convertCoodinatesPowerToJson(&coordinatesPower)

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

func convertCoodinatesPowerToJson(coordinatesPower *[]am.CoordinatePowerValue) string {
	jsonInfo, err := json.Marshal(*coordinatesPower)
	if err != nil {
		log.Error(err.Error())
		return ""
	}
	return string(jsonInfo)
}

func (ge *GisEngine) StartSnapshotThread() error {
	// Make sure ticker is not already running
	if ge.snapshotTicker != nil {
+41 −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

// Coordinates with their power values.
type CoordinatePower struct {

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

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

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

	// Reference Signal Received Power as defined in ETSI TS 136 214.
	Rsrp float32 `json:"rsrp"`
}
+28 −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

type Coordinates struct {
}
Loading