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

limit maximum routes and route coordinates in VIS

parent 28d68af4
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -593,6 +593,13 @@ func predictedQosPost(w http.ResponseWriter, r *http.Request) {
		return
	}

	// Set maximum number of routes
	if len(requestData.Routes) > 10 {
		log.Error("A maximum of 10 routes are supported in the sandbox")
		errHandlerProblemDetails(w, "A maximum of 10 routes are supported in the sandbox", http.StatusBadRequest)
		return
	}

	responseData := requestData // Both request and response have same data model

	for i, route := range requestData.Routes {
@@ -608,6 +615,13 @@ func predictedQosPost(w http.ResponseWriter, r *http.Request) {
			return
		}

		// Set maximum number of geo-coordinates for each route
		if len(route.RouteInfo) > 10 {
			log.Error("A maximum of 10 geo-coordinates are supported for each route")
			errHandlerProblemDetails(w, "A maximum of 10 geo-coordinates are supported for each route", http.StatusBadRequest)
			return
		}

		var geocoordinates []gisClient.GeoCoordinate
		for _, routeInfo := range route.RouteInfo {
			// empty location attribute will cause a runtime error: invalid memory address or nil pointer dereference