Around the world on a motorbike

For the last 3 years I have been almost exclusively providing cartographic services for Bezdroza, one of the largest tourist guide publishers in Poland. Bezdroza has a distinguished protfolio of books and therefore the maps they publish may vary a lot, although they are usually rather guide-like maps like:

This time I was invited as a cartographer to take a part in a project that appeared to be quite unusual - I was to design maps for a book of travel. Nothing unusual so far, rigth? The unusual part was that the book was not to have any maps inside, the maps were supposed to make the cover of the book.

The book tells a story of two journalists that decided to travel around the world on their motorbikes. When they agreed it would be a great fun, they did not have their motorbike driving licenses nor they could ride the bikes. This made me think that it should be fun for me too to design such a cover for this book.

The data came from the Natural Earth data repository and from the GPS tracks supplied by the authors of the book.
For the front cover map I used the the 1:100M data set and generalised GPS data; for the back cover both source datasets were generalised even further.

When designing the 17 globe maps for the back cover I was tempted to script the data preparation process (prepare the data, center and project it, and finally clip it) though after all I took the quicker path and decided to create them manually. Maybe next time, when we are about to design some globe maps for the folks that visited more than 20 countries ;-)

Designing these maps was an enjoyable experience, hopefully you'll like them too.

Front cover:

Back cover:

Both covers:

Higher res files:

Front cover (3,11 mb)

Back cover (2,13 mb)

Both covers (6,14 mb)

A generic error occurred in GDI+

Recently I have been working on a tile serving utility that would generate tiles on the fly but also cache them at the same time for future usage. After releasing our map tiling tool for manifold this was the next step.

The tile rendering functions were working nicely and the process was fairly quick so enabling data caching functionality could only speed things up ;-) So far so good... It was supposed to be just a matter of saving the output bitmap to a file... So I did it the way I usually do and tried to save my tile this way:

mapImageBitmap.Save(path, _outputTileFormat);

 Apparently this was throwing an error. A very descriptive one: A generic error occurred in GDI+... Not very helpful, is it?

After googling for a while it looked like this was supposed to be a permissions problem but allowing my IUSR to write to the specified folder did not help at all. What's worse I have found some info on the msdn that one should avoid using the System.Drawing namespace in ASP.NET: Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.

Nice huh?

Another solution I found on the web was to clone the bitmap in question and then save it, though that gave the same error. No avail in my case.

Luckily after messing with the problem a bit more I have discovered that writing a bitmap to a memory stream and then saving the data using Sytem.IO.File.WriteAllBytes did the trick:

System.IO.MemoryStream outStream = new System.IO.MemoryStream();
mapImageBitmap.Save(outStream, _outputTileFormat);
System.IO.File.WriteAllBytes(_requestedTilePath, outStream.ToArray());

Defitions of Polish projections for manifold

With version 8.0.19 manifold team added some of the Polish projections to manifold projection presets. Basically they added five zones of the National Coordinate System 1965 (PUWG 1965, zones I, II, III, IV and V). There seems to be a mistake though with the way they named the projections: National Coordinate System 1965 was named 1942 while the only one that has 5 zones for Poland is 1965.

For those interested in using Polish coordinate systems with manifold attached is a custom projection xml (it will display in a folder Poland_Custom in the assign / change projection dialog). This is the best we came up with so far so please bear in mind that it may not be 100% perfect. For some more details please see a discussion at georeference.org.

Styling Navteq data using Manifold

Recently we were asked to prepare some map layers for a web application. The exercise was about styling Navteq 2010 data in manifold so created maps can be then used for rendering a tiled base map but also used by a map server.

Although manifold lacks some of the carto tools available in other GIS packages or graphic software it does offer enough to complete such task. It actually does offer some other functions that let one create some nice map features - for example the road shields labels were created from a drawing linked to a SQL query that created road label points spaced evenly along the road lines. This backed with the automatic resolution of label conflicts allowed us to nicely place the road shields on the map.

Cutting image from a bigger raster source

This script has already been posted on the georeference.org (http://forum.manifold.net/forum/t99935.7) so nothing new will be presented...

There was one interesting thing though - how to get from a bbox of a geom used by the input drawing to the actual size of the output image in pixels. The script needed to cut images and preserve their actual resolution - as one would crop an image in photoshop.

First I had to prepare a coordinate converter and to grab some data off the image coordinate system needed later for calculating the actual size of a cut image in pixels:

//prepare coordinate converter in order to properly calculate image extent in pixels later
Manifold.Interop.CoordinateConverter coordConverter = manApp.NewCoordinateConverter();
coordConverter.Prepare((Manifold.Interop.Base)map.CoordinateSystem, (Manifold.Interop.Base)inputImage.CoordinateSystem);

//also grab the input image local scales
double imageLocalScaleX = inputImage.CoordinateSystem.ParameterSet["localScaleX"].Value;
double imageLocalScaleY = inputImage.CoordinateSystem.ParameterSet["localScaleY"].Value;

The next step was to grab the bounding box of a source geometry used to cut a new image from the source raster:

//grab the bounding box of an object
Manifold.Interop.Rect geomBbox = geomSet.get_Item(n).Box;

After that I used the bottom left and top right corners of the bbox and coverted them to the source image coordsys in order to calculate the size of the new image in pixels:

//get the corner points of the geom's bbox
Manifold.Interop.Point bottomLeft = manApp.NewPoint(geomBbox.XMin, geomBbox.YMin);
Manifold.Interop.Point topRight = manApp.NewPoint(geomBbox.XMax, geomBbox.YMax);

//convert them to the image coordsys
coordConverter.Convert((Manifold.Interop.Base)bottomLeft, null);
coordConverter.Convert((Manifold.Interop.Base)topRight, null);

//image size in pixels
int imageSizeX = (int)((topRight.X - bottomLeft.X) / imageLocalScaleX);
int imageSizeY = (int)((topRight.Y - bottomLeft.Y) / imageLocalScaleY);

//and then cut tile
map.RenderAreaTo(fileName, imageSizeX, imageSizeY, geomBbox, true);

Fairly straight forward isn't it?

Anyway, if you would like to use this script it is attached below. There are some input params and they need to be set prior to running the script. The reason behind using a RenderAreaTo method of a map object instead of the image object is explained in the script.

Although perhaps it would be easier to use gdal for the task than writing a script this exercise seemed to be interesting enough to give it a go. Having a GUI environment to choose areas of interest by simply drawing a rectangle over the image is a good reason isn't it ;-) Make sure though you switch off the input drawing before rendering the new images...

Also bear in mind that if you work with a high resolution ecw for example, the image you want to cut may be quite large since and the script calculates its size based on the source image resolution - to make it simpler: trying to cut a too big image out of a high res source image may make your pc unresponsive for a longer time ;-)

EDIT: I would almost forget - the input drawing is expected to have a column with names for the new images.

tileCutter.cs (7.53 kb)