Bílý vrch
icon TrekBuddy
www.trekbuddy.net
Outdoor companion.
  • internal / bluetooth / simulator GPS
  • offline raster maps
  • smart GPX / raw NMEA logs
  • waypoints and simple navigation
  • custom views
  • MIDP and Symbian phones
  • Blackberry
  • Android
Visit wiki to see all features, guides and howtos. Project tracker.

Partners:    (Polish/Polski)(Polski) Compass mapy      (Polish/Polski)(Polski) Galileos mapy      (Polish/Polski)(Polski) CartoMedia      (Czech/Èesky)(Èesky) Eaglesoft trasy      (Polish/Polski)(Polski) ExpressMap     

 FAQFAQ   SearchSearch   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Another tool to download maps
Goto page 1, 2, 3, 4, 5, 6, 7, 8  Next
 
Post new topic   Reply to topic    TrekBuddy Forum Index -> Tools
View previous topic :: View next topic  
Author Message
s_bostjan



Joined: 09 Jan 2007
Posts: 12

PostPosted: Fri Jan 26, 2007 6:01 am    Post subject: Another tool to download maps Reply with quote

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!



GoogleHackPureJava.zip
 Description:

Download
 Filename:  GoogleHackPureJava.zip
 Filesize:  17.38 KB
 Downloaded:  2111 Time(s)

Back to top
View user's profile Send private message
s_bostjan



Joined: 09 Jan 2007
Posts: 12

PostPosted: Fri Jan 26, 2007 6:29 am    Post subject: 256 tiles Reply with quote

For those whose phones don't handle well the generated 512 pix tiles, here is a version of the program that makes 256pix tiles.


GoogleMapsShare256.zip
 Description:

Download
 Filename:  GoogleMapsShare256.zip
 Filesize:  31.68 KB
 Downloaded:  898 Time(s)

Back to top
View user's profile Send private message
kruch
Site Admin


Joined: 02 Jul 2006
Posts: 5665

PostPosted: Fri Jan 26, 2007 5:31 pm    Post subject: Reply with quote

Shocked Shocked Fantastic!!! Very Happy

... how about decreasing bit depth, to, say, 8bpp?
Back to top
View user's profile Send private message
s_bostjan



Joined: 09 Jan 2007
Posts: 12

PostPosted: Fri Jan 26, 2007 9:31 pm    Post subject: converted to 8bpp Reply with quote

there you go....


program.zip
 Description:

Download
 Filename:  program.zip
 Filesize:  20.2 KB
 Downloaded:  651 Time(s)

Back to top
View user's profile Send private message
yaworski



Joined: 08 Jan 2007
Posts: 64

PostPosted: Sat Jan 27, 2007 3:14 pm    Post subject: Reply with quote

s_bostjan thank you for your tool, it is great Smile. 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
View user's profile Send private message
s_bostjan



Joined: 09 Jan 2007
Posts: 12

PostPosted: Sat Jan 27, 2007 10:53 pm    Post subject: Reply with quote

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.



program.zip
 Description:

Download
 Filename:  program.zip
 Filesize:  20.87 KB
 Downloaded:  302 Time(s)

Back to top
View user's profile Send private message
yaworski



Joined: 08 Jan 2007
Posts: 64

PostPosted: Sun Jan 28, 2007 12:52 am    Post subject: Reply with quote

Yeah now it seems that it gets the maximum zoom level for my area (Warsaw).

This zoom thing is strange. For example please take a look at this:
http://maps.google.com/mapdata?latitude_e6=51503910&longitude_e6=131840&zm=4800&w=2000&h=2000&cc=us&min_priority=1
http://maps.google.com/mapdata?latitude_e6=51503910&longitude_e6=131840&zm=4800&w=1000&h=1000&cc=us&min_priority=1

Those 2 maps are showing exactly the same area but with different complexity level.

----edit----

Could you take a look at mapexplore's implementation of the zoom levels for mapdata url?

Check the computesbaselinkvalue() method in map.html file. The level depends on the difference between right and left edge coordinates and desired predefined zoom levels defined by google api (bigger number, more zoom, 18 is maximum value). This should be easy to port to Java.
Back to top
View user's profile Send private message
s_bostjan



Joined: 09 Jan 2007
Posts: 12

PostPosted: Sun Jan 28, 2007 7:21 pm    Post subject: Reply with quote

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)


program.zip
 Description:

Download
 Filename:  program.zip
 Filesize:  23.43 KB
 Downloaded:  283 Time(s)

Back to top
View user's profile Send private message
sarebro



Joined: 12 Jan 2007
Posts: 4

PostPosted: Mon Jan 29, 2007 1:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
s_bostjan



Joined: 09 Jan 2007
Posts: 12

PostPosted: Mon Jan 29, 2007 1:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
kruch
Site Admin


Joined: 02 Jul 2006
Posts: 5665

PostPosted: Mon Jan 29, 2007 2:40 pm    Post subject: Reply with quote

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
View user's profile Send private message
yaworski



Joined: 08 Jan 2007
Posts: 64

PostPosted: Mon Jan 29, 2007 3:02 pm    Post subject: Reply with quote

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 Smile. So I can only do some interface to it Smile.
Back to top
View user's profile Send private message
s_bostjan



Joined: 09 Jan 2007
Posts: 12

PostPosted: Mon Jan 29, 2007 6:38 pm    Post subject: Additional parameter.... Reply with quote

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.



Program.zip
 Description:

Download
 Filename:  Program.zip
 Filesize:  16.35 KB
 Downloaded:  1046 Time(s)

Back to top
View user's profile Send private message
yaworski



Joined: 08 Jan 2007
Posts: 64

PostPosted: Mon Jan 29, 2007 6:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
s_bostjan



Joined: 09 Jan 2007
Posts: 12

PostPosted: Mon Jan 29, 2007 6:57 pm    Post subject: Reply with quote

You can use any value u want so 300x300 is legal.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    TrekBuddy Forum Index -> Tools All times are GMT
Goto page 1, 2, 3, 4, 5, 6, 7, 8  Next
Page 1 of 8

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group