Thousands of years ago nobody could even dream of such a thing as GPS.
Sailors and travelers coped well with navigation using a compass, maps, the sun
and the stars. It’s the digital era now but nevertheless, there are many ways to
determine the location without using global positioning systems.

No doubt, GPS is a great thing, but what if you don’t have a receiver? Not
everyone has a cell phone with a built-in GPS chip and the car owner doesn’t
necessarily has bought it either. So what to do in that case? There’re three
main things you can do considering no rare and exotic options:

  1. You can determine your IP address and then use a special database to get
    the location of your city. Those databases often include city’s longitude
    and latitude.
  2. You can determine the location of the next-door GSM / UMTS base station.
    This thing works only if you have the towers coordinates and identifiers
    database.
  3. You can also use the nearby Wi-Fi access points to calculate the
    latitude and longitude. You just have to send a certain request to a special
    server including their characteristics.

Let’s start with the simplest one.

 

Using IP address

When I need to check my external IP address (e.g. I want to be sure I’m using
a VPN or a proxy) I always use the ip2location.com service. Except of the
IP-address information you can get the provider information, its location (city,
country, state), and it’s coordinates as a rule. Of course, you won’t be given
the latitude and longitude for the most ordinary Internet services consumer.
Typically, database specifies the provider info, at least for large companies
with large ranges of static IP. It turns out that you can determine your
approximate location by connecting some public hotspot or simply using a
computer. Of course this way is pretty primitive and the most inaccurate of all
presented in this article. On the other hand, it gives a real chance to
determine the location just with opening the Internet web-page. But if you’ll
thumper a special tracker, install it on the PDA and monitor the IP’s your PDA
receives while connecting the open Wi-Fi networks, then you can actually track
the device movement.

Pure service use (namely, following the ip2location.com link using a browser)
is lame n’ boring. You won’t be able to see your location on the map and save
the log file. Also the page itself is too heavy for GPRS Internet connection.
Long story short, it is not the way we do. The only thing we need from this
service is the “IP to location” database, which can be bought from
ip2location.com for quite reasonable rate. Of course, such databases are quickly
spread out on warez portals and torrent trackers. They appear in two different
versions: .cvs (the text one) and .bin (the binary one). It’s easy to tweak any
application to fit your needs with such database. However, the database has the
IP address information stored in a special digital form using no dots and octets
separation. The following PHP-function will transform that kind of IP address to
the common one:

function Dot2LongIP ($IPaddr)
{
if ($IPaddr == "") {
return 0;
} else {
$ips = split ("\.", "$IPaddr");
return ($ips[3] + $ips[2] * 256 + $ips[1] * 256 * 256 + $ips[0] * 256 * 256 *
256);
}
}

It won’t cost anything to find matching coordinates in the text database with
such an address key. The task is even easier if you have the .bin database.
Service provides ready-made modules for Perl, C, Python, PHP, Ruby, C #, VB.NET,
Java, Visual Basic (http://www.ip2location.com/developers.aspx) which are easy
to use in your project. It’s enough to upload the IP2Location.inc.php module and
create a simple script using PHP code:

<?php
include("IP2Location.inc.php");
$ip = IP2Location_open("samples/IP-COUNTRY-SAMPLE.BIN", IP2LOCATION_STANDARD);
$record = IP2Location_get_all($ip, "_IP-ADR_");
echo "$record->country_long : " . $record->country_long;
echo "$record->city : " . $record->city;
echo "$record->isp : " . $record->isp;
echo "$record->latitude : " . $record->latitude;
echo "$record->longitude : " . $record->longitude;
IP2Location_close($ip);
?>

With sending the latitude and longitude as a parameter you can simply log or
display your location on Google Maps:


http://maps.google.com/maps?f=l&hl=en&q=’+query+’&near=’+str(lat)+’,’+str(lng)+’&ie=UTF8&z=12&om=1

 

Using cell phone towers!

An old tale telling that special services can find a bad guy using a signal
of one’s cell phone is one of those cases when in fact it’s so. F*ck those
special services, that thing can be done even by a completely free Google Maps
software (www.google.com/gmm).

In fact, it’s just convenient software to access the like named Web service
that allows you to view the location pictures from the satellite, location
topography, and in most cases it gives an opportunity to blaze a trail.

It’s extremely difficult to deal with such a site through your cell phone
browser (even if you have a high-speed Opera Mini browser). That’s why Google
hurried up and made a convenient interface for viewing maps.

It was released as an application based for different cell phone platforms,
starting from a traditional Java supported cell phone, smartphones and
communicators based on Windows Mobile and Symbian S60 3rd Edition platforms to
prestigious BlackBerry, and Android which is pretty offbeat at the moment but
very soon will be seen as one of the main cell phone platforms. E.g. iPhone has
the default integrated Google Maps utility. In addition to comfortable map and
satellite images viewing, this utility has a great "My location" button. One
click and your cell phone will be marked on the map. This feature will be a
perfect rot for those who have a handset integrated GPS receiver. That’s no news
for them! But you should see faces of those users’ that see their location on
the screen having no navigation devices! However, it only seems so.

The handset is always under the coverage of at least one network base station.
Or maybe it’s not but in such case it worth of neither more nor less than a
brick. Every base station has a certain set of parameters, which are received by
the cell phone thereby each BS can be identified. One of those parameters is
CellID (abbreviated as CID) — a unique cell number issued by operator. If you
have that ID you can identify the base station and its location relatively, so
you can understand where you are. Accuracy varies from a few hundred meters to
several kilometers, but it is a good starting point to deal with coordinates.

So, if you have the table where each base station will be accordingly mapped
to its coordinates, we can roughly calculate the subscriber position. And since
Google Maps can determine the location of subscriber so recklessly, it has to
have such kind of database. But where did they get it from? Location of
different operators’ base stations is not a secret, but is unlikely to open
information. That’s pretty difficult to believe that Google agreed with all
cellular network operators (even paying tribute to magnitude of its projects)
because location identification works in any place (a little ahead, I’ll say
that "can be ran anywhere" is right to say). The answer lies in the license
agreement which appears during utility installation, which we, of course, scored
and immediately clicked "I agree":). But there is black and white, that by
accepting the agreement, we allow the program to send the server information
about the current location and information on cell towers nearby, anonymously.
Yes! The database with approximate coordinates of base stations is made by
Google’s “Google Maps” users who have their cell phones and communicators with
integrated GPS receiver. And what is most great: the function of location
determination works great even with the complete renunciation of the use of both
formal and informal (collected by enthusiasts with special scanners — read more
in the sidebar) stations location database. Check yourself.

 

GSM-navigation with one’s own hands

The ability to look up a location is a great thing, but is it possible to
resist the temptation to pimp Google’s database? What do you think of an idea to
create your own tracker which would determine the current BS location and send
it to your server? Your cell phone will be a kind of a bug which works at all
times and in all places!
Google doesn’t disclose the Google Maps communication protocol. They don’t
publish the API, but it can be easily opened using simple traffic sniff and
reversing a part of the script code. While loading maps it can be clearly seen
that in addition to http-requests the program sends requests to

http://www.google.com/glm/mmap
, precisely when the user wishes to obtain the
current location. So the script is on the hook. Base Station technical
parameters (MCC, MNC, LAC and CellID) are sent as script parameters.

MCC — country code (250 for Russia)
MNC — network code (MTS — 01, Megaphone — 02, Beeline — 99, etc.)
LAC — Local area code (in other words – spread of base stations which are served
by one controller)
CellID (CID) — the identifier consists of a number base station and sector

You just need to get these values! The simplest way is getting it directly in
Google Maps software. Enter the "Help" menu, then click on "General information"
and browse the page bottom. There will be a line with those parameters we need.
It’ll be displayed in the following format myl: MCC: MNC: LAC: CellID. You’ll
have much more options using some special software like netmonitor. You’ll be
able to log settings when switching from station to station, get the "neighbors"
parameters (located in the field of view of other BS), or simply get much more
detailed information using that software. There’re different versions of
netmonitor software that have different capabilities so you can choose the one
you like depending on your demands and platform.

Now we have all necessary parameters, so we can post a request to the server
and try to get some answer. To do that we’ll use a simple Python script, that
was created by Skvo:

net, cid, lac = 25002, 9164, 4000
import urllib
a = '000E00000000000000000000000000001B0000000000000000000000030000'
b = hex(cid)[2:].zfill(8) + hex(lac)[2:].zfill(8)
c = hex(divmod(net,100)[1])[2:].zfill(8) + hex(divmod(net,100)[0])[2:].zfill(8)
string = (a + b + c + 'FFFFFFFF00000000').decode('hex')
try:
data = urllib.urlopen('http://www.google.com/glm/mmap',string)
r = data.read().encode('hex')
if len(r) > 14:
print float(int(r[14:22],16))/1000000, float(int(r[22:30],16))/1000000
else:
print 'no data in google'
except:
print 'connect error'

To run it, we’ll need the Python interpreter (2-nd version is
required, won’t be run on 3-rd one), which can be downloaded here

http://python.org/download/releases
. It’s easy to guess, that you should put
your NET (MCC and MNC are written together), CID, LAC values in the script first
line. As a result, it will generate and send a request to the

http://www.google.com/glm/mmap
server. If there’s a base station using these
parameters mentioned in the database, then the screen would display coordinates,
for example, "59.200274 39.836925". Otherwise, the script will generate an error:
«no data in google». Those people who like programming can easily add a couple
of code lines. E.g. You can get the approximate sector coordinates by examining
all CID options (from 1 to 65536) with referred NET and LAC values and see which
ones are in Google database. If you feel like fooling with those scripts we’ve
added the GUI software written in C # (source code is provided) on our CD. Also
in this case you’ll get a link that displays the coordinates on the Google Maps
web-page.

It seems pretty interesting that the server is being sent only
three parameters (LAC and CellID values are key values). MCC / MNC values are
needed in the case of LAC, CellID pair coincidence. The cell phone can receive
much more information about the current station (like signal power) but these
options are not used in the calculations. The algorithm turns out to be
extremely simple. One sector is one coordinate. It’ll be the same coordinate
regardless of whether the user is 100 meters close to the base station or a
kilometer away from it!

Separately, I want to say that the great "Yandex.Maps" project,
which I particularly love for the points display opportunity, has the same
functional. It offers its program data point on request with an indication of
Cell ID, LAC, NET parameters exactly the same way as Google does:

http://mobile.maps.yandex.net/cellid_location/?&cellid =%d&operatorid
=%d&countrycode =%d&lac=% d

The only difference is that the "Yandex" service returns the
answer in the XML-format, which can be easily and conveniently parsed to get any
parameters.

 

About cellular network base stations

I mentioned the informal databases in the article. They
consist of cellular towers location information of different cellular
networks. There are many projects in the Internet where enthusiasts share
information gathered with netmonitors. E.g.,
celldb.org/aboutapi.php,

www.opencellid.org/api
,
gsmloc.org/code
,
cellid.telin.nl
. Each has a simple API to get the coordinates with the
usual HTTP-request using traditional MCC, MNC, Cell ID and LAC parameters.
Separately, I want to mention our Russian Netmonitor.ru project which
gathered tons of information about MegaFon, MTS, Beeline, Tele2 and even
Skylink base stations. In addition, there’s also a major forum for cellular
networks researchers.

 

How to make the navigation software work

To put it mildly, no matter how great is Google Maps, using it
as a navigational tool is rather difficult. It would be great to feed those
approximate, but still coordinates to some normal navigation software, with good
maps, detailed addressing and well developed algorithms of lining the route.
Some programs, e.g., "Navitel" and "AVTOSPUTNIK" have another advantage: they
know how to load information about traffic jams and take it into account when
drawing up the route. Theoretically, nothing worth writing such an application
by oneself. The algorithm is simple:

  1. Get the current coordinates at each base station change;

  2. Send a request to the satellite and get the approximate
    coordinates;

  3. Emulate a serial port in a simple NMEA format, which is used
    by GPS-navigators;

  4. Broadcast the current coordinates there.

These principles are used in VirtualGPS software (www.kamlex.com).
This utility was created to use on Windows Mobile 2003, WM 5, WM 6, WM 6.1
platform based devices. Free Lite utility version allows determining the current
location of cellular towers and emulates GPS. This utility creates a new serial
port that you’ll have to specify in the settings of your favorite navigation
software so it will suspect nothing and will assume that there’s a real
connected GPS-receiver.

 

What can Wi-Fi do?

Being annoyed by the fact that most WiFi-points in your city are
either closed or paid, think about how they can be used a different way. I think
we won’t discuss how :). The principle is the same: after identifying all nearby
access points, we should send the information about the MAC-address (adding
network SSID identifier if desired) to a special service. It checks their
coordinates and gives you your approximate location. Such technology has been
operating in the U.S. for a pretty long time. The Wi-Fi coverage is off scale
there and it seems that none can escape from it. The SKYHOOK Wireless Company (www.skyhookwireless.com)
provides the WPS (Wi-Fi Positioning System). They have collected the initial
base with access points and developed some custom applications for different
platforms. Soon there appeared some alternative API using services. There’s a
wonderful plug-in for Firefox called Geode among them (http://labs.mozilla.com/geode_welcome).
It adds the information about the current location on any Web site (e.g. when
creating a new post in the blog).

Alas, I didn’t succeed with making SKYHOOK work in Russia. But
our countrymen took up the implementation of such ideas pretty closely. They’ve
released the Wi2Geo service (www.wi2geo.ru),
which for some reason I really want to call Wi2Go :). Guys now offer
applications for Windows Mobile, Symbian, Windows and Mac OS X platforms. They
use IP-addresses database, some information about GSM cells and, in fact, Wi-Fi
access points, for navigation. No one disallowed using their database for one’s
own purposes. We can do it using an open API (http://labs.wi2geo.ru/basicapi.php).
The only thing that upsets is that the project will develop only in those cities
that have a large Wi-Fi coverage. And Moscow is the only one city that can be
called at the moment.

 

What about tracking?

A bit above we talked about subscriber tracking. What is it?
It’s a system that allows a real-time subscriber position tracking on the map.
That would be great if all friends had such a thing installed on their cell
phones. Then it would cost nothing to know where everyone is and arrange a
meeting if necessary. Guys from Google have implemented that feature in Google
Latitude utility that recently has become available again to cell phone Google
Maps users. Unfortunately, you’ll be able to view your friends’ location through
a browser only from US territory, but nothing prevents to use an American proxy?

There is another option. Here

http://forum.xda-developers.com/showthread.php?t=340667
you can download a
special tracking utility for free. The client-side is installed on the
communicator based on WM, and the server-side can be installed on any web server.
Then object’s position can be viewed via Google Earth software. This is a real
working business solution which (in the view of open source) can be easily
refined to one’s needs.

 

WWW

Google Maps parameters:

http://mapki.com/wiki/Google_Map_Parameters

Interfacing an AVR controller to a GPS cell phone

http://tinkerlog.com/2007/07/13/interfacing-an-avr-controller-to-a-gps-mobile-phone

“Get the cell coordinates using Yahoo” manual:

http://developer.yahoo.com/yrb/zonetag/locatecell.html

Implementation of work with Google Maps database

PHP:

http://www.witracks.com.br/gmaps.txt

j2me:

http://www.mapnav.spb.ru/site/e107_plugins/forum/forum_viewtopic.php?9736

android:

http://www.anddev.org/poor_mans_gps_-_celltowerid_-_location_area_code_-lookup-t257.html

C#:

http://www.sebbi.de/archives/2008/04/25/google-maps-mylocation-in-c-sharp

Python for S60:

http://blog.jebu.net/2008/07/google-cell-tower-mapping-with-python-on-s60

C#:

http://maps.alphadex.de/datafiles/fct0e1b11782832f02.cs

Java for Android OS:

http://davanum.wordpress.com/2007/12/01/android-much-better-geo-location-from-just-cellidlac

Delphi:

http://forum.netmonitor.ru/about4470-0-asc-60.html

Оставить мнение

Check Also

Как Apple обходит стандарты, заставляя тебя платить. Колонка Олега Афонина

Иногда сложные вещи начинаются с простых: планшет iPad Pro 10.5 вдруг перестал заряжаться …