When I use search engines for certain searches, mostly related to maps or commercial establishments, these systems often serve me relevant results for my geographical location.
When I'm on the PC, search engines may not even know my geographical location with GPS accuracy, but they know at least which city I am in.
I believe this is determined by the IP address, since a specific address range is usually provided by the provider for well-defined regions.
But at the implementation level, how is this determination made? Is there a formula for determining the city or region of the user from their address? Or at least one known provider from which we can consume a service to obtain this information?