Tuesday 25 March 2008

DeepZoom in Silverlight 1.0 (part deux)

One of the 'issues' I found with using DeepZoom output in Silverlight 1.0 was the irregular shape of DeepZoom Composer's (Mermaid) output -- the entire 'image' is not square, nor are the right/bottom edge tiles.

These two simple examples shows how 'Mermaid' thinks: it will fill up tiles from top-left, leaving the bottom-right tiles "just" big enough to encapsulate the source image.


That's fine for Silverlight 2.0 MultiScaleImage controls to work with, since it can 'cheat' during layout, using the data in info.bin/info.xml to figure out how many Image controls to dynamically create.


But for a basic tile-client (of the sort that can easily display map tiles) that expects the source data to be a perfect square, the basic 'Mermaid' output is "too efficient".

Enter the MakeSquare console application...

It needs a little bit of 'tuning' (the "base" zoom level is hardcoded), but it basically walks a DeepZoom Composer output directory and
  1. makes all tiles square
  2. fills in missing tiles to make each 'zoom level' square
like this basic example (currently working best in Firefox :-s )...

Wednesday 19 March 2008

DeepZoom "Publisher"

Firstly, a quick note about hosting Silverlight 2.0 on 'locked down' hosting providers (ie. where you can't set the MIME type for the .xap extension to application/x-silverlight-app) and you follow the advice to change the extension to .zip... it doesn't seem to work when your Silverlight 2.0 application uses DeepZoom/MultiScaleImage! I can't explain why, but my DeepZoom test doesn't work (currently; request is in to set the MIME types) even when Tim's test page does (on my server).

Anyway, until my hosting provider fixes the server, here's what this page should look like:


which of course pans/zooms with a little help from Scott Hanselman and the Expression team blog


Pretty easy to do with the DeepZoom Composer, but even easier with a little program that takes an Adobe Acrobat/PDF file and generates everything for you!


You'll need the following:and you will get a complete MultiScaleImage 'set' (info.bin, info.xml and a whole piled of numbered directories). Check Scott H and the Expression team posts on wiring it up.


UPDATE (20-Mar): now that my hosting provider has added the .XAP extension, the demo works. To 'prove' that renaming to .ZIP fails when using MultiScaleImage, this is an identical page with .XAP renamed to .ZIP, both in the object tag and the file itself (obviously).

Thursday 13 March 2008

DeepZoom in Silverlight 1.0

DeepZoom (ex-SeaDragon) is a very cool 'application' of the image-tiling concept used in online maps like google and live maps/virtual earth.

There are (well, seem to be) two 'modes' for DeepZoom: with or without a 'Collection'; where 'Collection' seems to mean each element of the image has it's own set of tiles and can be treated individually.

It is the 'Collection' mode that allows the Hard Rock Cafe Memorabilia to slide images around when you choose different categories (by artist, type, decade, genre, location). When a 'Deep Zoom Collection' is created, each element has it's own folder within which the tiles are grouped by zoom level. It's easy to conceptualise how this model will 'scale up' to PhotoSynth where each element exists not just in a 2D space but in a 3D space with corresponding 3D positioning (but with the same basic metadata that supports DeepZoom Collections now) residing in the info.bin/info.xml files. Of course building the 'composer' for PhotoSynth will be orders of magnitude more difficult :)

Anyway, back to DeepZoom... when you do NOT generate a collection,

DeepZoom Composer (Mermaid) generates the ENTIRE SCENE in a single set of zoom-level-grouped images... awfully similar to the way map tiles are cut, and this is where it gets interesting!

If you already have (coincidentally) a Silverlight 1.0 "Tile Client" and map browser running, it would be a simple matter to change your google topographic image location template (for example) from
var gridPos = quadkey.charAt(quadkey.length-1);
var t = new Tile(quadkey, WORLD.Zoom)
var nz = 17 - WORLD.Zoom;
imageUrl = 'http://mt'+gridPos+'.google.com/mt?n=404&v=w2p.63&x='
+t.Column+'&y='+t.Row+'&zoom='+nz+'';
to
var nz = 9 + WORLD.Zoom; // DeepZoom idiosyncrasy
imageUrl = '/ClientBin/DeepZoomMags/'+nz+'/'
+t.Column+'_'+t.Row+'.jpg';
and be able to navigate a DeepZoom image using Silverlight 1.0!

This example is NOT live on the web (for now), screenshots follow to prove it works:




Just to tie this back to Geoquery 2008, the same Tile Client code exists in C#/WPF so it would also be trivial to modify the configurable MapSources.xml to browse a DeepZoom (NON-Collection) image from a WPF application...

NOTE: there are known issues with this approach, including DeepZoom Composer not generating a perfect 'square' of source images, and trimming 'edge' images to the size they need to be rather than 'squares' (causing stretching on the right & bottom edges). Both would be simple to cater for in a purpose-built Silverlight 1.0 DeepZoom viewer.

Tuesday 4 March 2008

Geoquery 2008 v0.72

Another minor release of Geoquery 2008 to finish off some of the 'known bugs' around line and polygon rendering... It can be downloaded here.

First up, Morten has helped fix a number of bugs in Geoquery, and this release is no exception. While trying out his OGC conformance test map I discovered some GEOMETRY idiosyncrasies I still hadn't fixed. If you read his post and download the schema/data, this sql works best in Geoquery.


Morten also pointed out the issue with holes... (notice how the GEOGRAPHY instance is rendered on both the Shape & Map tabs!)


And finally, after a month away from the code (some of it at the beach :) it was relatively quick to solve most of the problems around 'wrapping': with a bit more help from Ed Williams I was able to discard my previous efforts (using the SqlTypes) and solve the problem with some basic math - hoorah!




I expect it will be a bit of a wait for the next version of this code. I have a lot of ideas to incorporate, some of which require further architectural changes. I will also update the Examples to discuss the new features in CTP6. Until then - enjoy Geoquerying...

Monday 3 March 2008

Back to "work" on Geoquery

After a great holiday at the beach, a rushed implementation of PayPal, some silverlight prototyping and fighting with IL at work, I've finally found some time to work on Geoquery again.

v0.8 is pretty ambitious, so it's likely to be an interim version that fixes a few more bugs, such as polygons that cross +/- 180 degrees Longitude.


and Geography displayed on the Shapes tab


and the dodgy example from my last post


Still a little more to do (what about when the polygon disappears above +/-85 degrees Latitude), but hopefully I'll be back working on street-level maps 'any time now'.



p.s. yeah, I went to the "2008 launch wave". What I don't get is when headlines that look like {data binding} became cool marketing?