Commit b48784e3 authored by Simon Pastor's avatar Simon Pastor
Browse files

yaml file update

parent 77112896
Loading
Loading
Loading
Loading
+156 −0
Original line number Diff line number Diff line
@@ -249,6 +249,73 @@ paths:
          description: "Not found"
        500:
          description: "Internal server error"
  /geodata/{assetName}/distanceTo:
    get:
      tags:
      - "Geospatial Data"
      summary: "Get distance between geospatial data points"
      description: "Get distance between geospatial data for the given asset and another\
        \ asset or geospatial coordinates"
      operationId: "getDistanceGeoDataByName"
      produces:
      - "application/json"
      parameters:
      - name: "assetName"
        in: "path"
        description: "Name of geospatial asset"
        required: true
        type: "string"
        x-exportParamName: "AssetName"
      - in: "body"
        name: "distanceParameters"
        description: "Parameters of geospatial assets"
        required: true
        schema:
          $ref: "#/definitions/DistanceParameters"
        x-exportParamName: "DistanceParameters"
      responses:
        200:
          description: "OK"
          schema:
            $ref: "#/definitions/DistanceResponse"
        404:
          description: "Not found"
        500:
          description: "Internal server error"
  /geodata/{assetName}/withinRange:
    get:
      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: "withinRangeParameters"
        description: "Parameters of geospatial assets"
        required: true
        schema:
          $ref: "#/definitions/WithinRangeParameters"
        x-exportParamName: "WithinRangeParameters"
      responses:
        200:
          description: "OK"
          schema:
            $ref: "#/definitions/WithinRangeResponse"
        404:
          description: "Not found"
        500:
          description: "Internal server error"
definitions:
  AutomationStateList:
    type: "object"
@@ -283,6 +350,38 @@ definitions:
    example:
      active: true
      type: "MOBILITY"
  DistanceParameters:
    type: "object"
    properties:
      assetName:
        type: "string"
        description: "Asset name of a second element for query purpose. If present,\
          \ latitude and longitude are ignored."
      latitude:
        type: "number"
        format: "float"
        description: "Latitude of a second element for query purpose. Taken into account\
          \ only if AssetName is not present."
      longitude:
        type: "number"
        format: "float"
        description: "Longitude of a second element for query purpose. Taken into\
          \ account only if AssetName is not present."
    description: "Parameters for distance query purpose."
    example:
      latitude: 0.8008282
      assetName: "assetName"
      longitude: 6.0274563
  DistanceResponse:
    type: "object"
    properties:
      distance:
        type: "number"
        format: "float"
        description: "Distance between two points (in meters)"
    description: "Distance response"
    example:
      distance: 0.8008282
  GeoDataAssetList:
    type: "object"
    properties:
@@ -295,6 +394,9 @@ definitions:
  GeoDataAsset:
    allOf:
    - type: "object"
      required:
      - "assetName"
      - "assetType"
      properties:
        assetName:
          type: "string"
@@ -320,6 +422,60 @@ definitions:
          - "CLOUD"
    - $ref: "#/definitions/GeoData"
    description: "List of geospatial data"
  WithinRangeParameters:
    type: "object"
    required:
    - "radius"
    properties:
      assetName:
        type: "string"
        description: "Asset name of a second element for query purpose. If present,\
          \ latitude and longitude are ignored."
      latitude:
        type: "number"
        format: "float"
        description: "Latitude of a second element for query purpose. Taken into account\
          \ only if AssetName is not present."
      longitude:
        type: "number"
        format: "float"
        description: "Longitude of a second element for query purpose. Taken into\
          \ account only if AssetName is not present."
      radius:
        type: "number"
        format: "float"
        description: "Radius (in meters) around the location."
      accuracy:
        type: "number"
        format: "float"
        description: "Accuracy of the location (in meters)."
    description: "Parameters for within range query purpose."
    example:
      latitude: 0.8008282
      assetName: "assetName"
      accuracy: 5.962134
      radius: 1.4658129
      longitude: 6.0274563
  WithinRangeResponse:
    type: "object"
    properties:
      latitude:
        type: "number"
        format: "float"
        description: "Asset latitude"
      lontitude:
        type: "number"
        format: "float"
        description: "Asset longitude"
      within:
        type: "boolean"
        description: "Within range result (e.g. true = within range, false = beyond\
          \ range)"
    description: "Within range response"
    example:
      within: true
      latitude: 0.8008282
      lontitude: 6.0274563
  GeoData:
    type: "object"
    properties:
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ To see how to make this your own, look here:
[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md)

- API version: 1.0.0
- Build date: 2021-04-27T13:27:39.348-04:00
- Build date: 2021-05-28T11:51:37.253-04:00


### Running the server
+8 −0
Original line number Diff line number Diff line
@@ -36,10 +36,18 @@ func GetAssetData(w http.ResponseWriter, r *http.Request) {
	geGetAssetData(w, r)
}

func GetDistanceGeoDataByName(w http.ResponseWriter, r *http.Request) {
	geGetDistanceGeoDataByName(w, r)
}

func GetGeoDataByName(w http.ResponseWriter, r *http.Request) {
	geGetGeoDataByName(w, r)
}

func GetWithinRangeByName(w http.ResponseWriter, r *http.Request) {
	geGetWithinRangeGeoDataByName(w, r)
}

func UpdateGeoDataByName(w http.ResponseWriter, r *http.Request) {
	geUpdateGeoDataByName(w, r)
}
+114 −0
Original line number Diff line number Diff line
@@ -1106,6 +1106,120 @@ func geGetAssetData(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, string(jsonResponse))
}

func geGetDistanceGeoDataByName(w http.ResponseWriter, r *http.Request) {
	// Get asset name from request path parameters
	vars := mux.Vars(r)
	assetName := vars["assetName"]
	log.Debug("Get GeoData for asset: ", assetName)

	// 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.StatusNotFound)
		return
	}

	// Find asset in active scenario model
	node := ge.activeModel.GetNode(assetName)
	if node == nil {
		err := errors.New("Asset not found in active scenario")
		log.Error(err.Error())
		http.Error(w, err.Error(), http.StatusNotFound)
		return
	}

	// Retrieve Distance parameters from request body
	var distanceParam DistanceParameters
	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(&distanceParam)
	if err != nil {
		log.Error(err.Error())
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	if distanceParam.AssetName != "" {

		// Find second asset in active scenario model
		node := ge.activeModel.GetNode(assetName)
		if node == nil {
			err := errors.New("Asset not found in active scenario")
			log.Error(err.Error())
			http.Error(w, err.Error(), http.StatusNotFound)
			return
		}
	}

	// Create Response to return
	var resp DistanceResponse

	// Format response
	jsonResponse, err := json.Marshal(&resp)
	if err != nil {
		log.Error(err.Error())
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

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

func geGetWithinRangeGeoDataByName(w http.ResponseWriter, r *http.Request) {
	/*
	   // Get asset name from request path parameters
	   vars := mux.Vars(r)
	   assetName := vars["assetName"]
	   log.Debug("Get GeoData for asset: ", assetName)

	   // Retrieve query parameters
	   query := r.URL.Query()
	   excludePath := query.Get("excludePath")

	   // 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.StatusNotFound)
	           return
	   }

	   // Find asset in active scenario model
	   node := ge.activeModel.GetNode(assetName)
	   if node == nil {
	           err := errors.New("Asset not found in active scenario")
	           log.Error(err.Error())
	           http.Error(w, err.Error(), http.StatusNotFound)
	           return
	   }

	   // Create GeoData Asset to return
	   var asset GeoDataAsset

	   // Format response
	   jsonResponse, err := json.Marshal(&asset)
	   if err != nil {
	           log.Error(err.Error())
	           http.Error(w, err.Error(), http.StatusInternalServerError)
	           return
	   }

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

func geGetGeoDataByName(w http.ResponseWriter, r *http.Request) {
	// Get asset name from request path parameters
	vars := mux.Vars(r)
+38 −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

// Parameters for distance query purpose.
type DistanceParameters struct {

	// Asset name of a second element for query purpose. If present, latitude and longitude are ignored.
	AssetName string `json:"assetName,omitempty"`

	// Latitude of a second element for query purpose. Taken into account only if AssetName is not present.
	Latitude float32 `json:"latitude,omitempty"`

	// Longitude of a second element for query purpose. Taken into account only if AssetName is not present.
	Longitude float32 `json:"longitude,omitempty"`
}
Loading