Пример #1
0
        private static List <Tuple <double, double, bool> > getPoints(RequestClassSpots input)
        {
            List <Tuple <double, double, bool> > points = new List <Tuple <double, double, bool> >(input.Spots.Length);

            Spot[] spots = input.Spots;

            foreach (Spot spot in spots)
            {
                // notice 0 means true here!!!
                bool infoBool = spot.Info == 0;
                points.Add(Tuple.Create(spot.Lon, spot.Lat, infoBool));
            }

            return(points);
        }
Пример #2
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            log.Info("C# HTTP trigger function processed a request.");

            // Get request body
            dynamic data = await req.Content.ReadAsAsync <object>();

            // Set name to query string or body data
            RequestClassSpots  inputSpots  = (RequestClassSpots)data?.spots.ToObject(typeof(RequestClassSpots));
            RequestClassParams inputParams = (RequestClassParams)data?.parameters.ToObject(typeof(RequestClassParams));

            List <Tuple <double, double, bool> > points = getPoints(inputSpots);
            Dictionary <string, string>          parametersDictionary = convertParamsToDictionary(inputParams);

            //testing
            foreach (Tuple <double, double, bool> entry in points)
            {
                log.Info(entry.ToString());
            }

            //testing
            foreach (string str in parametersDictionary.Keys)
            {
                log.Info(str);
            }

            //testing
            foreach (string str in parametersDictionary.Values)
            {
                log.Info(str);
            }


            List <ISpatialmHGResult> spatialmHGResults = getSpatialmHGResults(points, parametersDictionary);

            log.Info("test2!!!!");
            ResponseClass output = new ResponseClass(convertResultsToResponse(spatialmHGResults));

            return(inputSpots == null
                ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a request body")
                : req.CreateResponse(HttpStatusCode.OK, output.ToString()));
        }