Client program for an advertising company. A person glues himself a sticker on the glass and rolls around with it in the city advertising something. There is a condition: the advertiser pays only for the claim within the city. So, is it possible to implement a check on the android, is the person inside the city or not?

Kilometer should be considered only if the object moves inside the city. I need to know how many miles he drove through the city. And do not turn off the GPS itself, but make a check if the object has left the city - he will not consider the mileage until he returns to it ....

How to implement such a check programmatically?

  • four
    IMHO this is insanity. You can turn it off, but how can you turn it back on when the object enters the city - the GPS is turned off, respectively, you will never know whether it drove back to the city or not :) Think first about the logic. - Barmaley
  • @Barmaley agree, perhaps the author should not turn off the GPS, but only increase the interval between sending data - user2455111

1 answer 1

I am afraid that you will have to outline each city where it works manually on a map using polygons. If the polygon is not convex, then split into several convex and check whether the GPS coordinate falls into your polygon using one of the methods from this article