private void ExtractCoordinates(TravelInformation travelInformation, string[] coordinatesSections, string[] sectionInfo)
        {
            for (int i = 0; i < coordinatesSections.Length; i++)
            {
                var sectionList = coordinatesSections[i].Split(new[] { "#*#" }, StringSplitOptions.RemoveEmptyEntries);
                var pathInfo    = sectionInfo[i].Split('|', StringSplitOptions.RemoveEmptyEntries);

                var coordinates = new List <RouteCoordinates>();

                foreach (var item in sectionList)
                {
                    var coordinateSplitted = item.Split('$', StringSplitOptions.RemoveEmptyEntries);
                    foreach (var latLong in coordinateSplitted)
                    {
                        var latLongSplitted = latLong.Split(' ');
                        coordinates.Add(new RouteCoordinates
                        {
                            Longitude = latLongSplitted[0],
                            Latitude  = latLongSplitted[1]
                        });
                    }
                }


                var routeStep = _mapper.Map <RouteStep>(pathInfo);
                routeStep.Coordinates = coordinates;
                routeStep.StepIndex   = (i + 1).ToString();

                travelInformation.RouteSteps.Add(routeStep);
            }
        }
        private async Task <List <Route> > ExtractContent(HttpResponseMessage response, bool coordinates = true)
        {
            var routes = JsonConvert.DeserializeObject <IEnumerable <RouteViewModel> >(await response.Content.ReadAsStringAsync());

            var routeOptions = new List <Route>();
            int routeIndex   = 0;

            foreach (var route in routes)
            {
                routeIndex++;

                var routeOption = new Route();

                var travelInformation = new TravelInformation();

                var contentSplitted     = route.Result.Split(new[] { "#---#" }, StringSplitOptions.RemoveEmptyEntries);
                var coordinatesSections = contentSplitted[1].Split(new[] { "#-#" }, StringSplitOptions.RemoveEmptyEntries);
                var sectionInfo         = contentSplitted[2].Split(new[] { "#-#" }, StringSplitOptions.RemoveEmptyEntries);

                var htmlToJson = await contentSplitted[0].ToJsonGenericMode();

                var htmlResult = JsonConvert.DeserializeObject(await htmlToJson.Content.ReadAsStringAsync());

                var contentResult = JObject.Parse(await htmlToJson.Content.ReadAsStringAsync());

                travelInformation = _mapper.Map <TravelInformation>(contentResult);
                if (coordinates)
                {
                    ExtractCoordinates(travelInformation, coordinatesSections, sectionInfo);
                }

                routeOption.TravelInformation = travelInformation;
                routeOptions.Add(routeOption);
            }

            return(routeOptions);
        }