Personal Projects

Printomi Maps

Well since we have made the decision to discontinue Printomi I have been backing up the databases and downloading the 90GB+ of images that users have uploaded.

Well it wouldn’t be like me if I didnt start thinking about what cool things I do with all those pixels. I remember seeing those cool Mincraft maps that use the Google Maps API to explore the Minecraft servers and it got me thinking if it could be possible to do something like that but for the Printomi images.

Well it turns out yes, you can: http://www.mikecann.co.uk/projects/PrintomiMaps/

Its only 1,024 of the total 27,497 images that were uploaded but even this small ratio results in a total map size of 115,200 x 86,400 pixels. The Google Maps obviously cant handle an image that large and it would take forever to download so you must split it up into many tiles. To achieve the zooming and performance you must also provide the map at various sizes.

With a map of 32×32 image with each image at 3600×2700 pixels and each tile at 450×337 this results in 87,000 tiles at 8 zoom levels! Generating and uploading all that data takes several days. But the result is you can pan and zoom around what seems like one huge 115k x 84k image.

If you are interested I have uploaded the source code I wrote to generate the 87k tiles at the various zoom levels from the 1024 3600×2700 input images. You can find it over on Github: https://github.com/mikecann/PrintomiMaps

If I had enough disk space on my web server I would love to do the whole 37,000 images in this way. If I did 128×128 that would use 16,384 of the images. This would result in 10 zoom levels and a map 460,800 x 345,600 pixels large. I have no idea or how long it would take to generate and upload all those tiles :P

URI Parser For HaXe

Continuing on my theme of the moment haXe, I have another post  regarding the development of my haXe rewrite of  ChromeCrawler.

I was in need of a way to split a URL into its various parts. To do this in previous versions of ChromeCrawler I used a ready built one I found on the web.

I thought it should be a fairly simple matter to port this to haXe, unfortunately however this wasn’t the case. The problem was that haXe, unlike JS, doesnt have the exec() method on its regular expression function. What this meant is that the URL couldnt be split in the same way.

Confused I jumped on the haXe IRC, unfortunately the solutions the kind people there provided didnt work. Instead I posted a message on the mailing list and within a few hours I had my answer. The solution was to use EReg.match() then EReg.matched() to get each part.

Anyways, I promised to share the code when I was done so here it is:

package utils;
import haxe.Http;
 
/**
 * ...
 * @author mikecann.co.uk
 */
 
class URLParser
{
	// Publics
	public var url : String;
	public var source : String;
	public var protocol : String;
	public var authority : String;
	public var userInfo : String;
	public var user : String;
	public var password : String;
	public var host : String;
	public var port : String;
	public var relative : String;
	public var path : String;
	public var directory : String;
	public var file : String;
	public var query : String;
	public var anchor : String;
 
	// Privates
	inline static private var _parts : Array<String> = ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];
 
	public function new(url:String)
	{
		// Save for 'ron
		this.url = url;
 
		// The almighty regexp (courtesy of http://blog.stevenlevithan.com/archives/parseuri)
		var r : EReg = ~/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
 
		// Match the regexp to the url
		r.match(url);
 
		// Use reflection to set each part
		for (i in 0..._parts.length)
		{
			Reflect.setField(this, _parts[i],  r.matched(i));
		}
	}
 
	public function toString() : String
	{
		var s : String = "For Url -> " + url + "\n";
		for (i in 0..._parts.length)
		{
			s += _parts[i] + ": " + Reflect.field(this, _parts[i]) + (i==_parts.length-1?"":"\n");
		}
		return s;
	}
 
	public static function parse(url:String) : URLParser
	{
		return new URLParser(url);
	}
}

So for example the following use:

trace(new URLParser("http://www.mikecann.co.uk/programming/haxe/haxe-jqueryextern-gotcha?somevar=1242#home"));

Will print the following:

For Url -> http://www.mikecann.co.uk/programming/haxe/haxe-jqueryextern-gotcha?somevar=1242#home
source: http://www.mikecann.co.uk/programming/haxe/haxe-jqueryextern-gotcha?somevar=1242#home
protocol: http
authority: www.mikecann.co.uk
userInfo: undefined
user: undefined
password: undefined
host: www.mikecann.co.uk
port: undefined
relative: /programming/haxe/haxe-jqueryextern-gotcha?somevar=1242#home
path: /programming/haxe/haxe-jqueryextern-gotcha
directory: /programming/haxe/haxe-jqueryextern-gotcha
file:
query: somevar=1242
anchor: home

Simples!

Im not sure how performant the reflection usage would be on the various platforms haXe targets but atleast it would work and its fairly elegant to boot ;)

Edit: Thank you Adrian Cowen for posting this as a haXe snippet: http://haxe.org/doc/snip/uri_parser

Inputtie – Beta Drawing Near!

Final testing is under way here at mission control for the Inputtie Beta.

1 Keyboard, 1 Mouse, 1 PC, 2 Laptops, 1 Netbook, 4 Operating Systems.

All systems are go! Almost ready for takeoff!

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25  Scroll to top