Question

I currently have a service area system based on zipcodes, customers would enter an address(zipcode) and it would return the available service times for their service area (a service area can have multiple zipcodes), what I need to do now is instead of using zipcodes to create service areas I need to use a boundary system where I can draw polygons on a map and when customers enter an address we would geocode it and compare against the service area and return appropriate service time, a system like this would be more accurate because the problem I have now is that zipcode boundaries are of very different shapes and it is impossible to make an accurate service time map. I'm having problems thinking of an easy way to accomplish this.

Was it helpful?

Solution 2

After researching deeper on this topic, I found what I was looking for!, I could use the ray-casting algorithm to spot a point(coordinates) inside a polygon, the polygon's coordinates I can easily get from Google maps, In essence what I will be doing is:

  1. Make a Google maps area selector to build polygons.
  2. Save polygons point coordinates array to database.(as service region/area)
  3. Geo-Code customers addresses and save to DB as well (First time will pull from Google maps and save on DB for future use). 4.Use the Ray-Casting Algorithm to loop through all the "polygons" until it returns true and we would know to what polygon the address belongs to, if it returns false then we know we don't service that area.

References:

Raycasting algorithm with GPS coordinates

http://rosettacode.org/wiki/Ray-casting_algorithm

OTHER TIPS

to get you started: Google Maps tutorial

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top