Sunday, July 18, 2010

Article: Geographic Location Services

Long back, I was wondering on how application control users from accessing certain information’s without user based authorization in place. It all started when I used PlayStation 3 to connect online with PlayStation Network for downloading demo contents including games and media contents. I had to set-up an US based account as the service was not available in India. Upon setting up the account, I was able to browse through their catalogues and was even able to download games as I expected but was restricted access for the video store to download high definition media contents. After digging into the issue, found out that they are blocking access to that particular section through Geographic information (IP address) and not with the user account set-up.Another instance that brought me to write this blog was a similar requirement from one of our customer on the need for allowing particular functionality to be accessed only by certain users contracted and not the user outside the contracting market. Application and database being hosted in central environment, customers were looking at making use of a geographical location services based on IP addresses and in fact there are many services available in market. Most of the services gives data online and through API’s.

Following are the few categories of services/tools related to the Geo Information I got to know·

  • IP Locator – For locating the place from where the request came from. Like country, city, region etc. Useful to track user location to customize applications and suggest them the nearby services around their area such as shopping offers, generate site statistic reports based on the visitors to the sites from different countries etc·
  • Proxy Detector - For detecting users who bypass Geo location controls by using proxies to spoof their IP address and location
  • Spam Locator - For locating the geographical location that an email originated from·
  • Trace Route Locator – For locating the geographical location of IP Addresses·
  • Dynamic Redirection of internet surfers – For redirecting the user to the localized sites/geographic content etc·
  • Distance between two cities – To determine the distance between two cities/places

Just a sample to try out!! Following simple JavaScript code will enable us to find the basic Geographic location information’s based on the users current IP address and with the help of third party JavaScript API.

<html>
<head><title>Geo Location - User</title></head>
<script type="text/javascript" src="http://j.maxmind.com/app/geoip.js"></script>
<script>
function GetGeoInfo()
{
var info = document.getElementById('GeoInfo');
var lat = geoip_latitude();
var lon = geoip_longitude();
var city = geoip_city();
var out = '<h3>Information from your IP</h3>'+
'<ul>'+
'<li>Latitude: ' + lat + '</li>'+
'<li>Longitude: ' + lon + '</li>'+
'<li>City: ' + city + '</li>'+
'<li>Region: ' + geoip_region() + '</li>'+
'<li>Region Name: ' + geoip_region_name() + '</li>'+
'<li>Postal Code: ' + geoip_postal_code() + '</li>'+
'<li>Country Code: ' + geoip_country_code() + '</li>'+
'<li>Country Name: ' + geoip_country_name() + '</li>'+
'</ul>'
info.innerHTML = out;
}
</script>
<form name="GeoForm">
<body>
<div id="GeoInfo">Getting the User Geo Information</div>
<script>GetGeoInfo();</script>
</body>
</form>
</html>
HTML Response:Information from your IP
  • Latitude: 13.0833
  • Longitude: 80.2833
  • City: Madras
  • Region: 25
  • Region Name: Tamil Nadu
  • Postal Code:
  • Country Code: IN
  • Country Name: India

Reference Links:


No comments:

Post a Comment