Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Delivery System Logic for a Restaurant App

outimeoutime miamiPosts: 1New Users Noob
I'm trying to develop a delivery system for a restaurant, but I'm not sure how to approach this problematic. The restaurant has multiple locations, exactly five, four of them are in one state and the other one is in a different one.

They only do deliveries for each location depending of how far is it, they also have setup certain limitations for each location for example:

My idea will be:

Fetch users location on iOS (Accomplished)
Check if user location is inside of any Restaurant delivery radio. If so, set that location as the Store, if not, just show message that we don't delivery to their area.
Where I'm stuck

How can I define in Apple Maps the limits of Location 1, 2, 3, etc (meaning what area will they be doing delivery to.
Thank you.

Replies

  • dev666999dev666999 Posts: 3,594New Users @ @ @ @ @
    outime wrote: »
    I'm trying to develop a delivery system for a restaurant, but I'm not sure how to approach this problematic. The restaurant has multiple locations, exactly five, four of them are in one state and the other one is in a different one.

    They only do deliveries for each location depending of how far is it, they also have setup certain limitations for each location for example:

    My idea will be:

    Fetch users location on iOS (Accomplished)
    Check if user location is inside of any Restaurant delivery radio. If so, set that location as the Store, if not, just show message that we don't delivery to their area.
    Where I'm stuck

    How can I define in Apple Maps the limits of Location 1, 2, 3, etc (meaning what area will they be doing delivery to.
    Thank you.

    The simplest way is to create a circular area of delivery surrounding each restaurant. Lets make the radius equal to 10 miles.

    All you have to do is calc the distance as the crow flies from your buyer's location to the restaurant. If that distance is less than 10 miles, do the delivery, if not show the non-delivery message.
  • ryantcbryantcb Posts: 666Registered Users @ @ @
    edited November 2015
    The restaurants won't move so have their coordinates and use CLLocation's

    func distanceFromLocation(_ location: CLLocation) -> CLLocationDistance

    Then just loop through the restaurants and get distance nearest first and then check it is less than 10 miles. CLLocationDistance is in meters so 10 miles is 16,000m
Sign In or Register to comment.