3G/Edge/GPRS IP addresses and geocoding
We're looking to develop a mobile website. On this mobile website, we'd like to automatically populate a user's location (with proper fallback) based on their IP address. I'm aware of geocoding a location based on IP address (mapping to latitude, longitude and then getting the location with that information).
However, I'm curious how accurate this information is? Are mobile devices assigned IPs when they utilize 3G, EDGE, and GPRS connections? I think so. If that is so, does it map to a relatively accurate location? It doesn't have to be 开发者_StackOverflow中文版spot on, but relatively accurate would be nice.
Short answer: No.
The network assigns an IP address to the phone when the PDP context is activated (activation of PDP context is telecomms-speak for 'asking for packet data services'). It can be changed under network control, but this usually only happens when the connection has been dormant for some time.
You need to bear in mind that a typical mobile network may have several million users, and since signaling (i.e. address reconfiguration and the like) doesn't generate revenue, but costs the network scarce radio resources, it gets avoided as far as possible.
There is a further issue. Due to the architecture of mobile networks, if you have a visitor to a country who is operating using the roaming service with their home operator, they will in fact 'appear' to be in their home country. This is because the mobile device always connects to the internet through a node called the GGSN in their home network.
This is a major issue for websites which must deal with rightsholders. As an example, the BBC iPlayer service allows people located in the UK to 'catch up' on any BBC TV or radio content free of charge. In many cases, TV rights are geographically licensed, so the BBC is required to make every effort to ensure that the service is only available to users located in the UK.
This is, as I have explained above, impossible for mobile users. If I am using the SIM card of a UK network, I will 'appear' by geolocation to be in the UK regardless of where I actually am in the world.
This is not so much of a problem as yet: streaming a TV program over a 3G connection when roaming in a foreign network is prohibitively expensive (could easily be $100 or upwards for a single program), so this theoretical problem doesn't arise very often as yet. However, as roaming data costs fall (and everyone knows they will), it will become a real issue.
New smart phones (like Apple's iPhone) generally have web browsers that support HTML5 and/or some other form of client-side geolocation.
HTML5, for example, has the ability to geolocate the computer or mobile device based on a) position of the device's GPS, b) Wifi Triangulation and then c) IP address.
This is a client-side approach, and the browser will ask the user if they wish to share their location with you (which may or may not be a deal-breaker for you), but it is capable of providing < 20m accuracy.
See: About Geolocation in HTML 5
精彩评论