Monday, April 28, 2008

Satellite imagery for DSmaps

If you've played with the script from my last post you've probably noticed that gMapMaker has the ability to fetch satellite imagery from Google Maps as well as your basic street map tiles. After defining an area and zoom level and hitting go, you'll notice that two new directories are now under your cache, 'kh' with the sat pictures in Jpeg format, and 'tt' with the street map overlays as a transparent PNG. So if only we could combine these into the one PNG file, we'd be able to throw that into the QTRS to XYZ script and use them on our DSs. A bit of reading lead me to ImageMagick, which handily has a Perl module, PerlMagick.471 bytes of Perl script later we have a script to do what we want.

To use it you'll need ActivePerl which you should already have from the last script, and you'll also need to install the PerlMagick module. You can get this in the ImageMagick Windows Binaries, but the Perlmagick part of that install failed for me on XP SP2. To get mine working, after installing ImageMagick I had to follow the instructions in this post and then copy the .DLL files to my windows\system32 directory manually. If you have any trouble getting it installed, try the ImageMagick Forums for help.

After you've got those installed, drop the script in the same directory where you put the qrst2xyz one and create two new subdirectories, called 'sat' and 'streets'. Now copy the satellite .JPGs into the sat directory and their matching street map .PNGs into streets and run 'perl satcompo.pl' you should see the images being composited and dropped into your gtiles directory, all ready to be converted for DSmaps.

If you want to play with the quality of the outputted files, you can edit the line:
$sat->Set(depth=> 4);
to change the colour depth (in bits per channel). 4 is a good compromise between quality and read speed for me as my mini SD cards are a bit slow, but you may be able to get away with a value of 6 or even 8 for prettier images if you have some fast media.

Also keep in mind that DSmaps only goes down to zoom level 17, so don't bother trying to fetch and convert anything closer in than that.

Saturday, April 19, 2008

Gmaps to DSmaps converter

I've been playing around with the fantastic DS homebrew app DSmaps and found it pretty useful. One great feature is that it caches areas you've already viewed and you can go through them later (i.e. when you're out and about and get lost)

But what if you're lost and you haven't looked at that area already, and there's no free wifi around to grab those missing tiles? Well if you know you are going to be somewhere unfamiliar you could just pan around that area at various zoom levels before you leave hoping you've viewed everywhere you will be going and hope you don't miss anywhere, but ideally you'd be able to select a certain geographical area, downloads all the tiles for that space at all the zoom levels you want and have them ready to go. A bit of googling around led me to gMapMaker which lets you do just that, however it grabs the tiles in Google's QRST quadtree naming scheme, whereas DSmaps stores the tiles as a directory for the X coordinate, containing a subdirectory for the Y coordinate, which then contains the actual tile named as the zoom level. (once you get down past the 256 x 256 level X and Y data starts going into the filename as well, as DSmaps only uses a max 2 characters per directory)

So I thought as I'm wanting to learn how to write perl scripts I'd have a go at one to convert from the Gmaps naming to the DSmaps naming. I based it off a code snippet found here to figure out the X, Y and zoom values, then converted them to hex and used that to generate the DSmaps paths and files. You can grab the Perl script here. The script was written and tested on a Windows XP machine, no idea if it'll work on other platforms.

Before we get to using the script, a few notes. This is the 2nd script I've ever written, so it is probably not the best way of doing things, any pointers on how I could have done it better are welcome. BACK UP YOUR CARD FIRST. Sorry about the caps, but you never know when something might go wrong and I'm not responsible if your card gets corrupted, your dog catches fire and aliens enslave humanity due to this script. You can feel free to redistribute or modify the script as you see fit, however a credit or at least a link back to this post would be appreciated. If you do give it a go, please post a comment and let me know what you think.

Shutup already, how do you use the thing!

To use the script, you'll need to install Perl, which you can get for Windows from ActiveState. Once you've got that set up, put the script in a directory (doesn't matter where) and create a subdirectory under that called 'gtiles'. Fire up gMapMaker and enter the coordinates bounding the area you want to grab, the zoom level you are after and select 'driving maps only' and set the operating mode to 'Download tiles'. Click Go and once it grabs all the tiles you will find you have a directory called 'mt' in the cache folder which has a directory for each zoom level you have grabbed. Copy the files from these directories to the 'gtiles' directory you created (just the files, don't copy the directories themselves) and run the script ( go to a command prompt, change to the directory you dropped the script in and type 'perl qrst2xyz.pl'. If all goes well, you should see that you now have a directory structure suitable for DSmaps all ready to go, copy this over to the DSMAPS folder on the card you use in your DS and fire up DSmaps. You should now be able to pan and zoom around offline as long as you stay within the area and zoom levels that you have grabbed.

And because I know some of you will be thinking it, yes you could theoretically download all the tiles at all the zoom levels and have the entire planet (que evil genius laugh), however we are talking in excess of 270 million files here, weighing in at around 2.7 terabytes, so good luck finding a card to get that onto your DS :P.

Friday, May 18, 2007

unreliable poster

Another big break between posts, really need to work on that :/

So what's new? Still doing the vego thing, have lost a bit of weight and am also working out a bit more in an attempt to get a bit fitter for my big trip. Have booked accommodation in Munich and my trail pass for Maccu Piccu. They only let 500 people on the trail at any one time so need to get a permit months in advance. Savings towards actually paying for all this madness is going quite well, got some extra pay from work for a few things and had a string of lucky trades on the ASX, so I now have more in my trading account than the trip costs, if all else fails i can cash that in to pay for it.

enough for now, must try to post small interesting things every few days instead of forgetting a whole months worth......

Friday, March 09, 2007

The return

Ummm yeah, Hi.

Sorta forgot about this thing for the last year and a bit, but perhaps I'll start posting again. It's pretty much just for my own interest anyway because as far as I'm aware noone else reads it.

So what's new? In stark contrast to my previous post I have been a vegetarian for just over a month now, primarily for environmental reasons, but also for health and ethical reasons as well. Ironically it all came about because of radtrip, where each year we descend upon the sunshine coast to eat animals and drink booze and swim at the beach for a week straight. I had decided to try eating no meat for a month afterwards, but as I read more and more about the environmental impact the meat industry has on the planet, as well as the health benefits of a vegetarian diet I became interested in continuing it.

The other big news of the moment is that I will finally be embarking on the trip around the world that I've been talking about for years now in September. It will be a bit rushed, as I'm only taking 5 weeks off work, but I'll be going to Peru, England, Belgium, France, and finishing in Germany just in time for the end of Oktoberfest. Should be a lot of fun and I'm really looking forward to it, currently I'm saving as much money as a I can towards it and hopefully will be able to have it paid in full before leaving.

Well that's enough gibberish for a resurrection post, let's see if I manage to keep posting to this thing this time around.

Sunday, December 25, 2005

Gosh darn it's been a while

Hey what a surprise! I lost interest in blogging after a few short weeks! Well, hopefully that will change, but we'll see.

Well it's now officially Xmas, which is of course the time of year when we try to eat as much pig as possible. This is the real reason our Jewish and Muslim buddies don't celebrate this day. So today will feature bacon, ham, roast pork, and possibly other pieces of some poor hogs anatomy that I can get my hands on. As far as pressies go, my Girlfriend and I didn't get each other anything big, but instead shouted ourselves to a little pre-xmas holiday in Melbourne. The main motivation for this little journey to the deep south was to catch the excellent GreenDay world tour 2005, supported by my favourite band of the moment, Jimmy Eat World . The show was amazing, only real disapointments for me were the low volume and shortness of JEW's set, but GreenDay were pretty awesome putting in a full 2 1/2 hour set. I sorta wish I hadn't watched the 'Bullet in a Bible' DVD before hand as with such a big stadium production things have to be fairly tightly scripted and the shows were almost identical, but enough extra material was added to keep it fresh.

Our time in Melbourne was great, with the city really living up to it's reputation as the best place to eat and shop in Aus. Cafe's, restaurants and bars are absolutely everywhere, with every different variety of cuisine and price range you could ask for, and we probably would have had to take an extra few days for Kim to check out all the shops in Chappel st. The 2 things that really stood out for me though were how good the public transport system there is, and how terrible the road network is. It's not the roads are poor quality, it's just that it's totally disorganised, with poor signing, narrow streets, and seemingly no real defined main arteries to get you from one area to another. Driving in Brisbane is much simpler, and not just because it has half the population, but because you can look at a street directory and plot a course, then follow the signage to get there. Melbourne is the closest thing to driving in Malaysia that I've come across yet in Aus, luckily we could get most places on the excellent tram network and leave the car ( a rented BA Falcon, which had the cheapest crap tyres money could buy fitted) in the hotel carpark.

Monday, August 29, 2005

there be processed meat in me comments!!!

I got comment spammed!!! You know what this means don't you?!?! I AM SOMEBODY!!! Now please excuse me while I sit back and wait for the offers of freelance writing jobs and huge cash advances to start rolling in......and buy some viagra

Sunday, August 28, 2005

Reel Big Finger

Big news of late is that Reel Big Fish and Goldfinger are doing a show in Brisbane and I've just gotten my tickets, should be an amazing show. We'll be taking the SP23 on it's first run down the coast, and as long as things don't go the way of last time we saw Goldfinger, what shall forth be known as the Marlborough oddessy, then it'll be a great trip.

New job is great, I'm slowly learning Novell and Lotus Notes and have picked up a bit of overtime so the extra cash will be nice. It's my first RDO on monday, so I'll be savouring the 3 day weekend lifestyle of the public service worker with a lengthy gaming session on sunday night and some trading on monday. Tonight shall involve much playing of jenga, of which i am still undefeated champion. Will i retain my crown? place your bets now people....