Пример #1
0
        private void SearchForMidway(FilterEditModel filters)
        {
            GeoCoordinate searchCoordinate;

            // get itinerary from Google Directions
            GoogleItinerary     itineraryComputer = new GoogleItinerary();
            GoogleItineraryBase response          = itineraryComputer.GetItinerary(filters.PositionA, filters.PositionB);

            // push polylines to view for rendering
            Steps = new Dictionary <double, double>();
            foreach (var step in response.routes[0].legs[0].steps)
            {
                Steps.Add(step.end_location["lat"], step.end_location["lng"]);
            }

            // compute mid point ?
            // TODO

            // if google response is not relevant, use As The Crow Flies method
            searchCoordinate = MidPoint(filters.PositionA, filters.PositionB);
            Positions.Add(filters.PositionA.Latitude, filters.PositionA.Longitude);
            Positions.Add(filters.PositionB.Latitude, filters.PositionB.Longitude);

            InitLocationsByCoordinate(searchCoordinate, filters.OnlyOpenBars);
        }
Пример #2
0
        public SearchResultModel(FilterEditModel filters) : this()
        {
            Mode = filters.Mode;

            switch (Mode)
            {
            case FilterMode.Geolocation:
            {
                SearchForGeolocation(filters);
                break;
            }

            case FilterMode.Midway:
            {
                SearchForMidway(filters);
                break;
            }

            default:
            {
                SearchForDefault(filters);
                break;
            }
            }
        }
Пример #3
0
        private void SearchForDefault(FilterEditModel filters)
        {
            var backOffice = new BackOffice();

            foreach (Location location in backOffice.Locations)
            {
                if (filters.ZipCodes.Contains(location.ZipCode) && location.IsValid && (!filters.OnlyOpenBars || location.IsOpenNow))
                {
                    Locations.Add(location);
                }
            }
        }
Пример #4
0
        public SearchResultModel(FilterEditModel filters)
            : this()
        {
            Mode = filters.Mode;

            switch (Mode)
            {
                case FilterMode.Geolocation:
                    {
                        SearchForGeolocation(filters);
                        break;
                    }
                case FilterMode.Midway:
                    {
                        SearchForMidway(filters);
                        break;
                    }
                default:
                    {
                        SearchForDefault(filters);
                        break;
                    }
            }
        }
Пример #5
0
 public ActionResult SearchFromLocation(double latitude, double longitude, string open)
 {
     var model = new FilterEditModel(latitude, longitude, open);
     return View("Search", model);
 }
Пример #6
0
 public ActionResult SearchFromBetween(double latA, double lngA, double latB, double lngB, string open)
 {
     var model = new FilterEditModel(latA, lngA, latB, lngB, open);
     return View("Search", model);
 }
Пример #7
0
 public ActionResult Search(IList<string> zipcodes, string open)
 {
     var model = new FilterEditModel(zipcodes, open);
     return View(model);
 }
Пример #8
0
 private void SearchForGeolocation(FilterEditModel filters)
 {
     InitLocationsByCoordinate(filters.PositionA, filters.OnlyOpenBars);
     Positions.Add(filters.PositionA.Latitude, filters.PositionA.Longitude);
 }
Пример #9
0
        private void SearchForMidway(FilterEditModel filters)
        {
            GeoCoordinate searchCoordinate;

            // get itinerary from Google Directions
            GoogleItinerary itineraryComputer = new GoogleItinerary();
            GoogleItineraryBase response = itineraryComputer.GetItinerary(filters.PositionA, filters.PositionB);

            // push polylines to view for rendering
            Steps = new Dictionary<double, double>();
            foreach (var step in response.routes[0].legs[0].steps)
            {
                Steps.Add(step.end_location["lat"], step.end_location["lng"]);
            }

            // compute mid point ?
            // TODO

            // if google response is not relevant, use As The Crow Flies method
            searchCoordinate = MidPoint(filters.PositionA, filters.PositionB);
            Positions.Add(filters.PositionA.Latitude, filters.PositionA.Longitude);
            Positions.Add(filters.PositionB.Latitude, filters.PositionB.Longitude);

            InitLocationsByCoordinate(searchCoordinate, filters.OnlyOpenBars);
        }
Пример #10
0
 private void SearchForGeolocation(FilterEditModel filters)
 {
     InitLocationsByCoordinate(filters.PositionA, filters.OnlyOpenBars);
     Positions.Add(filters.PositionA.Latitude, filters.PositionA.Longitude);
 }
Пример #11
0
        private void SearchForDefault(FilterEditModel filters)
        {
            var backOffice = new BackOffice();

            foreach (Location location in backOffice.Locations)
            {
                if (filters.ZipCodes.Contains(location.ZipCode) && location.IsValid && (!filters.OnlyOpenBars || location.IsOpenNow))
                {
                    Locations.Add(location);
                }
            }
        }