| View previous topic :: View next topic |
| Author |
Message |
s_bostjan
Joined: 09 Jan 2007 Posts: 12
|
Posted: Fri Jan 26, 2007 6:01 am Post subject: Another tool to download maps |
|
|
After using mapexplore for some time, i decided to make my own program for downloading maps. With a bit of watching how things were done in mapexplore and with some help of other sites ( http://mapki.com/wiki) i made me a great tool that does just what i want.
But before i go and explain to you what it does, you must understand that it was made for me - by me. It was newer meant to be released outside of my disk. That's why this program has no exception catching, is not optimized and has some realy ugly code (in terms of programming practice) inside (and i think i saw a bug inside - but it sliped out of my hands). So don't pick on me!
What it does is it downloads maps from google inside a lon/lat start/end parameters. You can specify at which zoom the maps should be and the end name of the map files. The downloaded maps are then automaticaly calibrated. Then these maps are splited in smaller chunks and placed in map-name and set directory. The *.set listings and cr.tba file is also generated. In fact the downloaded maps are ready to be transfered to your phone and to be used by TB.
This is how you use it:
it is a java console program - so get java runtime. The program expect some input parameters:
- size of google maps pictures (they must be dividable by 256 and not greater then 2000) - i use 1792
- start longitude - 14.332
- start latitude - 46.222
- end longitude witch should be greater than start longitude - 20.045
- end latitude witch should be less than start latitude - 40.211
- zoom from 1 to 7 with 1 being most detail - 5
- name of the map - balkan
start it by entering: java -jar GoogleHackPureJava.jar 1792 14.332 46.222 20.045 40.211 5 balkan
when you start a program it then downloads and calibrates the maps. In the current directory it creates the folowing files:
balkan5000001.gif
balkan5000001.map
balkan5000002.gif
balkan5000002.map
...
...
These .gif file are 1792x1792 pix and named whith the map name input parameter, zoom value and a internal counter. When the program downloads all maps, it creates ./map/ subfolder and in there it creates other subfolders required by TB and splits these .gif files in .png tiles. You get something like this:
./map/cr.tba
./map/balkan5/balkan5000001/balkan5000001.map
./map/balkan5/balkan5000001/balkan5000001.set
./map/balkan5/balkan5000001/set/balkan5000001_0_0.png
./map/balkan5/balkan5000001/set/balkan5000001_0_512.png
...
...
./map/balkan5/balkan5000001/balkan5000002.map
./map/balkan5/balkan5000001/balkan5000002.set
./map/balkan5/balkan5000002/set/balkan5000002_0_512.png
...
...
The original .gif files are placed in ./ozi subfolder for backup/checking or whatever.
I don't know if the calibration is 100% right but it looks good. If anyone sees some bug - use the appended source code and change it (and please share it) - i wont be doing any more development on this code because i realy don't have any spare time left to doing this. So enjoy it!
| Description: |
|
 Download |
| Filename: |
GoogleHackPureJava.zip |
| Filesize: |
17.38 KB |
| Downloaded: |
2064 Time(s) |
|
|
| Back to top |
|
 |
s_bostjan
Joined: 09 Jan 2007 Posts: 12
|
Posted: Fri Jan 26, 2007 6:29 am Post subject: 256 tiles |
|
|
For those whose phones don't handle well the generated 512 pix tiles, here is a version of the program that makes 256pix tiles.
| Description: |
|
 Download |
| Filename: |
GoogleMapsShare256.zip |
| Filesize: |
31.68 KB |
| Downloaded: |
873 Time(s) |
|
|
| Back to top |
|
 |
kruch Site Admin
Joined: 02 Jul 2006 Posts: 5088
|
Posted: Fri Jan 26, 2007 5:31 pm Post subject: |
|
|
Fantastic!!!
... how about decreasing bit depth, to, say, 8bpp?
|
|
| Back to top |
|
 |
s_bostjan
Joined: 09 Jan 2007 Posts: 12
|
Posted: Fri Jan 26, 2007 9:31 pm Post subject: converted to 8bpp |
|
|
there you go....
| Description: |
|
 Download |
| Filename: |
program.zip |
| Filesize: |
20.2 KB |
| Downloaded: |
634 Time(s) |
|
|
| Back to top |
|
 |
yaworski
Joined: 08 Jan 2007 Posts: 64
|
Posted: Sat Jan 27, 2007 3:14 pm Post subject: |
|
|
s_bostjan thank you for your tool, it is great . And thank you for the sources of the application. I have a question. I set the zoom to 1 and I didn't get the maximal zoom available for this area. I this because the google java hack uses GoogleMaps API version 1.0? Is there a way to port this to version 2? There are more zoom levels in the newer version of the API.
|
|
| Back to top |
|
 |
s_bostjan
Joined: 09 Jan 2007 Posts: 12
|
Posted: Sat Jan 27, 2007 10:53 pm Post subject: |
|
|
You'r right. I didn't noticed. (i live in Slovenia and Google has some sh.t maps for greater zoom for our area)
This program uses no google api - it goes directly to a site where the browsers go when they have no javascript enabled. The fact with zoom is that i have no idea how to calculate it. When i download a map in size of 256pix with zoom 16800 i get a different zoomed picture then when i download a mapi with a size of 1024pix with zoom 16800.
So zoom must be calculated with size of the downloaded picture and some algorithm than i dont fully understand. (i used trial and error to get to those zooms)
see both maps and notice the zm parameter:
http://maps.google.com/mapdata?latitude_e6=51503910&longitude_e6=131840&zm=4800&w=256&h=256&cc=us&min_priority=1
http://maps.google.com/mapdata?latitude_e6=51503910&longitude_e6=131840&zm=4800&w=1792&h=1792&cc=us&min_priority=1
Now i added some more zoom levels so that the zoom parameter is a value between 1 and 10. Hope it helps. If not - you should play a little with the code in functions getGoogleZoomValue and getSlik256NaIzbranemZoomu.
I'm hoping someone would take the source code and make something of it. At least some checking of the calibration - i don't know nothing about map projections and that stuff. I'm guessing that the mathematical functions that were taken of the web and used in program are correct, but i wouldnt bet on it.
| Description: |
|
 Download |
| Filename: |
program.zip |
| Filesize: |
20.87 KB |
| Downloaded: |
294 Time(s) |
|
|
| Back to top |
|
 |
yaworski
Joined: 08 Jan 2007 Posts: 64
|
|
| Back to top |
|
 |
s_bostjan
Joined: 09 Jan 2007 Posts: 12
|
Posted: Sun Jan 28, 2007 7:21 pm Post subject: |
|
|
You'r right. Now the zoom is calculated the same way as in mapexplore. (but zooms are mapped: 8-17 in mapexplore is 10-1 in this tool)
| Description: |
|
 Download |
| Filename: |
program.zip |
| Filesize: |
23.43 KB |
| Downloaded: |
278 Time(s) |
|
|
| Back to top |
|
 |
sarebro
Joined: 12 Jan 2007 Posts: 4
|
Posted: Mon Jan 29, 2007 1:03 pm Post subject: |
|
|
Great!! I just found this, it´s just what I´ve been looking for... But one small thing is there any possibility to add an option to choose the size of generated tiles?? If the phone can handle for example 512x512 instead of 256x256 it would be nice to have a smaller number of tiles...
A big thank you!!!
/Andreas
|
|
| Back to top |
|
 |
s_bostjan
Joined: 09 Jan 2007 Posts: 12
|
Posted: Mon Jan 29, 2007 1:50 pm Post subject: |
|
|
| It's not difficult (only change ImageUtil->splitImage function) - but right now my time is very limited. Someone should take over my code and start doing something with it.
|
|
| Back to top |
|
 |
kruch Site Admin
Joined: 02 Jul 2006 Posts: 5088
|
Posted: Mon Jan 29, 2007 2:40 pm Post subject: |
|
|
| Perhaps... a page similar to mapexplore for area + zoom selection, to get parameters for s_bostjan's java code, and then invoke it ... put the code to applet and embed it in the page? (I'm not sure about security constraints for local disk access)
|
|
| Back to top |
|
 |
yaworski
Joined: 08 Jan 2007 Posts: 64
|
Posted: Mon Jan 29, 2007 3:02 pm Post subject: |
|
|
Applets can't do disk I/O operations unless they are signed (this can be self signed certificate AFAIK, user's approval is required). The idea is good. I'm now using s_bostjan's app together with mapexplore: I'm placing waypoints on map in mapexplore and then retrieve their coordinates by clicking on GPX button. This helps to visualize the area to be ripped in lower zoom levels before running the app.
I can try do something with the code. I was thinking rather on desktop application which would read for example gpx files (with only 2 waypoints defining area to be taken). But if it comes to geographical stuff I wont be able to do any modification because I don't know anything about this . So I can only do some interface to it .
|
|
| Back to top |
|
 |
s_bostjan
Joined: 09 Jan 2007 Posts: 12
|
Posted: Mon Jan 29, 2007 6:38 pm Post subject: Additional parameter.... |
|
|
I added an additional parameter on the end for size of tiles:
java -jar GoogleHackPureJava.jar 1792 14.332 46.222 20.045 40.211 5 balkan 512
If you don't enter it, 256 will be used.
| Description: |
|
 Download |
| Filename: |
Program.zip |
| Filesize: |
16.35 KB |
| Downloaded: |
1039 Time(s) |
|
|
| Back to top |
|
 |
yaworski
Joined: 08 Jan 2007 Posts: 64
|
Posted: Mon Jan 29, 2007 6:55 pm Post subject: |
|
|
s_bostjan what will happen when I put there tile size which is not 256 or 512px? Can I, for example, use 300x300? Can you add possibility to define different width and height (for map size and for tile size).
I'll look at the code on the weekend maybe and I'll try to do some user interface.
|
|
| Back to top |
|
 |
s_bostjan
Joined: 09 Jan 2007 Posts: 12
|
Posted: Mon Jan 29, 2007 6:57 pm Post subject: |
|
|
| You can use any value u want so 300x300 is legal.
|
|
| Back to top |
|
 |
|