1

enter image description here

this is a Taxi app where I have to calculate different interest rate for different zones in a big city, I have to devide the map to different zones, I know how to make polygons and draw shapes on map, but how can I make the map devise automatically to different zones with a certain size and know if a certain Location falls in any of the chosen zones?

Edit : here's another image to help you understand the problem better : enter image description here

the process is called surge pricing;

Taha Elkhaoua
  • 81
  • 1
  • 9
  • What about using the "tiles" coordinates to divide the zones (if your zone are not too fixed)? Tiles have and x,y,zoom triple of coordinate which define a specific area. – N Dorigatti Jun 13 '18 at 06:50
  • I dont quite get the idea of what "devise the map to different zones" means. Can you please draw a picture to make it clear? – Marian Paździoch Jun 13 '18 at 07:41
  • what I mean is using different prices for different zones in the city and I want make this process all automatic depending on the demand for the drivers in a certain area and display that to the client, here's a more detailed link : https://www.uber.com/en-MA/drive/partner-app/how-surge-works/ – Taha Elkhaoua Jun 13 '18 at 12:55
  • here's an image of what I need exactly : http://www.blogto.com/upload/2015/06/20150608-Uber.jpg – Taha Elkhaoua Jun 13 '18 at 12:56
  • I'd recommend a geohash solution with enough resolution (# of characters - e.g. 8 characters gives 0.02 km) to satisfy your requirements. This does two things: (1) divides your area into a spherical grid (which supports the pricing model) and (2) provides quick lookup for which grid element a client is in. –  Jun 14 '18 at 11:59

1 Answers1

1

It's not "one step solution" task. Here you can find description of main problems and ways to solve it (but for web and python, not for Android). In short you should:

1) determine where is water and where is land (for example, you can use this solution);

2) calculate scale factor for "Zone" depends on Google Maps Zoom level. You can use that code:

// Radius of the circle for current zoom level and latitude (because Earth is sphere at first approach)
double meters_to_pixels = (Math.cos(mGoogleMap.getCameraPosition().target.latitude * Math.PI /180) * 2 * Math.PI * 6378137) / (256 * Math.pow(2, mGoogleMap.getCameraPosition().zoom));
final int radius = (int)(meters_to_pixels * getResources().getDimensionPixelSize(R.dimen.ripple_radius));

from this;

3) actually draw zones (as polygones, GroundOverlays or something else).

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79