Tuesday, June 5, 2007

Google Map Downloader(2)

Today, I finished the first version google map downloader .

here is the user manual and some screen clips


The main screen display the world map in small scale, the default zoom level is 16 (the whole world as shown above), the actually Google map’s scale can vary from -2 to 17 ,but this Google map downloader only allow to download from 0 to 17,mainly because zoom 0 is large enough to show all the details.
Click the 4 direction arrow key moves the map, and click the + , - zoom in ,zoom out the map. And when move the mouse over the map, the current latitude/longitude is shown at right top area.(Current location)


Before downloading, you need to specify a rectangle area to be downloaded, “Top Left “ gives the top left point longitude/latitude pair, and “Right Bottom” gives the right bottom point’s longitude/latitude pair.
The longitude/latitude pair can be entered manually. Or use the current position , Press “Alt + A” sets the first point, “Alt + Z” gives the second point (right bottom).
Also you need to gives the zoom level ,valid value is from 0 to 17, 0 is the largest scale, 17 is the smallest scale.


Press “Start” , the downloader starts to download all the maps in given area. Press “Stop” stops the download.
The download maps is stored in current directory’s maps subdir.


China

If you want to download maps in China, remember to check the China “option”.
Download

Sunday, June 3, 2007

Google Map Downloader(1)

Based on what I have found about the Google map, I tried to download the entire Google map from Zoom Level 17 to Zoom Level 9. To my surprised, the total size of these pictures is about 123877653 byte; total number of files is 85191. Rough download time was around 10 hours. The average file size is 1.5K.
The general purpose Google map downloader is still under developing, here’s the screen snapshot. Should be done in weeks if I have enough free time :)

Saturday, June 2, 2007

Map Data Pre-process(5)

Mill Cylindrical projection


But with the formula shown above, calculating the x, y pixel based on the Latitude and longitude , the actually result has a big difference with the latitude shown in the Google map.
And with WGS84 the C# code list below
double RefLat=0;
double N0;
double q1,q2,q;
double dLat=srcLatitude;
double dLong=srcLongitude;
double CentralMeridian=0;
double x,y;
N0 = 6378137.0 / Math.Sqrt( 1-Math.Pow(0.081819190843,2)*Math.Pow(Math.Sin(RefLat*Math.PI/180),2) );
q1 = Math.Log( Math.Tan( (180.0/4.0+dLat/2.0)*Math.PI/180.0 ) );
q2 = 0.081819190843/2 * Math.Log( (1+0.081819190843*Math.Sin(dLat*Math.PI/180.0) ) /
(1-0.081819190843*Math.Sin(dLat*Math.PI/180.0) ) );
q = q1 - q2 ;
x = N0 * Math.Cos(RefLat*Math.PI/180.0) * ((dLong-CentralMeridian)/57.29577951) ;
y = N0 * Math.Cos(RefLat*Math.PI/180.0) * q ;

89.9999 (latitude)=88943153.2428999 (meter)
85.0207077431259(latitude)=19955741.4661156(meter)
31.9(latitude)=3727614.05671615(meter)

We know that when zoom level=7 , when latitude = -31.9 ,the y index of the tiles is 608
At first I thought , Google map the latitude range is from -90 to 90. but

3727614.05671615/88943153.2428999=21 . then plus 512 = 533 (far below 608)
I cannot figure out how Google use the map projection algorithm . I am a bit confused.
Then I remembered Google map API provides a API called fromDivPixelToLatLng() ,which computes the geographical coordinates from pixel coordinates in the div that holds the draggable map.
So I wrote a simple JavaScript ,then I found the max latitude Google map uses is 85.0207077431259.
(3727614.05671615/19955741.4661156+1)*512=607.63 (round to 608).

So here comes the final result. Google map uses WGS84 and the
Longitude [-180,180]
Latitude [-85.0207077431259, 85.0207077431259]

Wednesday, May 30, 2007

Map Data Pre-process(4)

Enter the following URL
http://mt1.google.com/mt?n=404&v=w2.52&x=841&y=608&zoom=7



Google maps show the Perth city. We know that the latitude and longitude is near -31.9 , 115.9
And we know for zoom level=7 ,the whole map is divided into 1024X1024 tiles
So x (longitude) , y (latitude)
Let’s do some calculation
X=841
841/1024*360-180=115.6 (approximately 115.9) (the degree of whole circle is 360)
Y=608
608/1024*180-90 =16.875 (much smaller than 31.9) (the degree of half circle is 180)
So this is not a simple or linear relation between x,y and longitude and latitude. Google maps uses some kind map projection algorithm.
Search for the most popular map projection algorithm. And understand the fact that meridians and parallels are equidistance, straight lines. Google map uses Simple Cylindrical projection. This projection is also known as Lat/Lon WGS84.


With the WGS84 map projection algorithm, we know each tile’s longitude and latitude, so can covert to method 2’s format.



Tuesday, May 29, 2007

Map Data Pre-process(3)

With the help of ethereal packet capturing, I analyzed the http request send to Google server.
http://mt1.google.com/mt?n=404&v=w2.52&x=841&y=608&zoom=7


Zoom can be value from -2 to 17 while for each zoom level, x, y can vary from 0 to 2 ^(17-zoom)-1

* Each tile is 256X256*4 = 256K, this is the maximum; normally a tile size is much less than 256K.


X is horizontal , Y is vertical , if using latitude/longitude X is 360。 , Y is 180。.
As motioned before, there’s another method to retrieve the map pictures using longitude and latitude:
http://google.com/mapdata?latitude_e6=-31900000&longitude_e6=115900000&zm=1000&w=256&h=288&cc=US
So what’s the relation between the 2 methods?

continue the analysis tomorrow.

Monday, May 28, 2007

Map Data Pre-process(2)

The following several blogs will talk about how to extract map data from Google map server. Currently I have found there are two methods to download map pictures from Google map server, but some request parameters I am still not very sure about it. Hope later I can find out.
Method 1:
http://mt1.google.com/mt?n=404&v=w2.52&x=111&y=76&zoom=10

Where mt0, mt1, mt2, mt3.google.com are the servers provides the same services, I assume Google uses the 4 server to balance the server load.

n=404&v=w2.52 ,don’t know the exact meaning, but it looks it keeps the same for all request.

X=111, y=76 are the column and row index of the map picture, Google divides the map into a serial of 256X256 tiles.
Zoom=10 ,zoom level
http://mt1.google.com/mt?n=404&v=w2.52&x=116627&y=73536&zoom=0

And it looks like x, y and zoom has some relations. Need to find out.

Method 2:
http://google.com/mapdata?latitude_e6=-31900000&longitude_e6=115900000&zm=1000&w=256&h=288&cc=US

latitude_e6 and longitude_e6 specify the longitude and latitude of the upper left corner of the map picture.
Zoom gives the zoom level (in meters)
w , h gives the width and height of the map picture.

All the URL gives the map picture, then it’s easy to write an application to download the map pictures automatically.

Friday, May 25, 2007

Map data pre-process(1)

To implement navigation software, suitable map data is critical. Not every map data is suitable for navigation purpose, and map data can be categorized to vector and raster data format. Raster map data and vector without topological information (like route connection data) can only be used for location purpose. With a GPS receiver, it can only tell where you are and nearby hotels, gas station. It’s hard to tell you how you can get to a place –the route to a destination. With link-node, link-link information, a route can be calculated so navigation is possible.
Based on the map data I can get, pocket streets China actually includes 2 products: Location and Navigation
Guidebee(Raster/Vector) Location
Guidebee(Raster/Vector) Navigation
Now comes the question, where can I get the original map data? One is from internet like Google map. An program can be written to exact the raster map data from Google map server and store the map images file to local disk for later use. Or online map with network connection.
Another way is buying map data from some map company. Currently I have some map data in MapInfo format. A parser program can be written to convert MapInfo tabs into access database, and then convert the access database into some specially designed map data for effective access.

Tuesday, May 15, 2007

Start "Pocket Streets China(guidebee)"

From today, I plan to start my navigation project; I have developed one called “Pocket Streets China” (nickname guidebee). Pocket Streets China is very like Microsoft’s pocket streets. And I have setup a website http://www.pstreets.com/ for this project. Actually the website was there for over year, I haven’t got much time updating it. Mainly because I was not quite familiar with Web application development, and recently I found a good training website (http://www.w3schools.com/), it is pretty good and gave me a lot of knowledge of HTML/XML/Javascripts etc. Though my website is still a bit simple, but the web demo looks goodJ, it uses Google map and some data I exacted from Australia UBD map software.
Navigation software involves a bunch of technologies, and I divided the who product into several module: GIS engine (GIS), Map matching algorithm (MMA), Routing algorithm (RA), navigation algorithm (NA) , map displaying (MD), GPS integration(GPS), audio prompt(AP) and anther one is map data preprocessing (MDP).
So the whole project is divided into several sub-projects.


Today is May 15th, 2007, it has been 6 months since I arrived Australia, I hope I can finish the project in 2 years in my spare time.