Archive for the 'Kosmos new versions' Category

Published by breki on 05 Jul 2009

Kosmos v2.5 And GroundTruth And Some Developer’s Musings

I finally managed to integrate my new digital elevation model (DEM) processing code into Kosmos. It was a lot more work than I anticipated, mostly because the existing Kosmos’ source code is getting large, difficult to maintain and even more difficult to introduce new functionality. For me it is the best example of why SOLID principles are not just a developers’ buzzword, but that they do have an impact on maintainability of the code as the code base gets larger and larger. Although Kosmos’ code is highly modular, uses all the paradigms of object-oriented programming, even uses inversion of control (IoC) containers quite a lot, this is not enough: certain portions of the code are pretty bloated with multiple responsibilities, which is a first no-no when we talk about SOLID principles: keeping the design clean by separating responsibilities into separate services/components.

When changing the code which serves more than one responsibility, it is difficult to separate these responsibilities and difficult to test the impacts. Unit tests in fact become mini-integration tests and you typically need more setup code in order for a test to be able to run. Which produces unit tests that are fragile and, like the “main” code, difficult to maintain.

I mentioned the usage of IoC containers (Castle Windsor actually). The problem is that you need some mileage to get things right: a common mistake is to drag the container around in your code and use it explicitly to create objects. This defeats the purpose of the IoC container: to wire things together without your intervention. I agree with Joshua Flanagan when he says that the “container” word was unfortunate choice: it should be called a “composer”. Kosmos was one of the first projects where I used an IoC container and it shows: there are a lot of things which I would have done differently now.

All the more reason for me to continue on my effort of rewriting the critical parts from scratch. But that’s a story for some other blog post.

Anyway, I hope the new IBF thing works. The bad news is that I needed to change/hack some code, so I cannot exclude a possibility of a bug or two. The other bad news is that the old “.dat” contours format is no longer supported, so you’ll need to recreate contours for your projects.

The good news, on the other hand, is that we switched to the NASA’s new SRTM server, since the old one has gone to retirement. And even more: the new IBF code is much better that the old Srtm2Osm one, the contours are now placed properly on the map, the contour generator now knows how to correctly ignore data voids and the contour files are much smaller.

I also made changes to GroundTruth to cut the produced IBF tiles exactly around the specified map boundary.

Oh yes, the download links:

Enjoy! And if you find the stuff I’m making useful, please consider a small donation. It will be used for books, software and equipment, all for the benefit of producing even better stuff in the future:


Published by breki on 20 Feb 2009

Kosmos 2.4 – Bugfix Release

We begin by charting a course
Creative Commons License photo credit: Dunechaser

Download link for the impatient ones:

After a long time (three months actually) a new version of Kosmos is out. It mostly contains fixes for bugs I detected while developing GroundTruth (with which Kosmos shares quite a lot of code). I haven’t really done any work on Kosmos directly ever since I started working on GroundTruth, but I hope to get back in development in the next few months.

One major issue that came up was the fact that a new (or not so new) OSM wiki URL scheme was not supported for rules source URL ( in addition to the old one This has now been fixed.

Goodies For The Upcoming 2.5 Release

I do have some other good news: very soon Kosmos will support the new OSM selector syntax that I developed for GroundTruth. This means that the expressions like

Kosmos New Rules 1

will now work in Kosmos. An extended support for selecting relations will also come in the same package:

Kosmos New Rules 2

I will also try to reuse GroundTruth’s wikitext parsing code which is more robust than the old Kosmos’ one, since it allows specifying table columns in more than one line of text.

Published by breki on 13 Nov 2008

Kosmos 2.3 – now with integrated slippymap!

UPDATE: A bug has already been discovered thanks to StefanB… a new download link for the fixed version.

There were some comments from this blog’s readers about me not delivering new Kosmos versions as promised :). So I decided to wrap up everything and produce a new version as soon as possible. Some things I planned for this release are postponed to the next version(s).


Last two to three weeks my main effort was in implementing the slippymap (web map) integrated directly into the main map. You can now view the whole Earth using one of OSM’s web maps (Mapnik, Osmarender, CycleMap). I find this to be a much better solution than opening an extra Web map browser window and then fiddling with map buttons like it was in previous versions. That’s why I plan to remove web map browser from Kosmos in future versions (unless some users find it useful, please let me know).

You can set the transparency of web map tiles so you can combine Kosmos rendering of OSM data together with the tiles. The slippymap tiles are also rendered on exported bitmaps and Kosmos’ web map tiles. I haven’t been able to show them on printed pages though, I have to investigate this further.

Icons can now be placed on areas:


Kosmos GUI now has a Full Map Mode switch which, when turned on, maximizes the map display and hides all other windows (see the screenshot at the top of the page). There is also a new Reload Rendering Rules menu item (and hotkey) to ease experimenting with rendering rules.

Another improvement is in Kosmos’ performance (both speed and memory-wise). I already wrote something about it in September. Anyway, you should be able to load larger chunks of OSM data now.

Below is a list of other new features and bugfixes for this release. As always, please let me know if you encounter any new bugs. The code base has changed a lot since the last version because of all the new features added to Kosmos, so there is always a chance of catching a bug or two…

  • BUGFIX: multiple rule selectors did not work with {{tag|key}} form
  • BUGFIX: density parameter for symbols wasn’t handled properly
  • generation of SRTM index can now be canceled by the user
  • BUGFIX: the generation of SRTM index sometimes hangs, probably due to FTP client command executing too quickly
  • when determining map boundaries, data files which are hidden are ignored
  • BUGFIX: when showing large bitmaps there are visible white horizontal stripes
  • changed the way how the OSM tags are stored in memory (array instead of Dictionary)
  • OSM reading code now ignores “created_by” tag – this results in a significant memory savings, since all of the nodes have this tag
  • BUGFIX: the map-related menus remained visible when the project was closed
  • implemented custom reading and writing of OSM XML files
  • various performance optimizations
  • BUGFIX: direct URLs for user pages containing rendering rules did not work
  • TextLineOffset-ing is now available for Node, AreaCenter and WayCenter text modes
  • added “Max zoom factor” setting to limit the allowed zoom level. This is in order to avoid application freezing up on high zooms.
  • Kosmos now uses arrays instead of Lists for storing way’s nodes list
  • added support for “bounds” osm tag, “bound” is now deprecated
  • BUGFIX: Color alpha value in map shading code is now checked not to exceed the allowed range
  • added User-Agent header when accessing Web

Published by breki on 25 Sep 2008

Kosmos 2.2

Yes, Kosmos has reached a new version (download the latest package from here). It contains some cool new features, but I have spent most of the work on improving the user experience. But let’s start with new features:

Mobile GMaps support

Kosmos maps on MGMaps screenshot

I’ve already blogged about this. In short, you can now use Kosmos-generated maps on with a Java mobile application called Moble GMaps (MGMaps). The idea is to generate map tiles from your Kosmos project, copy them to your phone and tell MGMaps to use them. Since the map is stored on the phone, you don’t need to use the mobile network or pay anything to view it. I’ll soon write instructions on how to set up the whole thing on the Kosmos OSM Wiki pages. UPDATE: the instructions are here.

Error list window

Kosmos GUI Error List Window

When loading projects, parsing rendering rules etc. Kosmos GUI will now display all the errors and warnings in a special “error list” window. This is combined with much improved handling of various errors in rendering rules – instead of causing Kosmos to crash, you should now be able to see all the detected errors in this window. In case some a parameter has an invalid value, the rendering rules engine will now use a default value – typical example is entering an invalid color value.

Handling of rendering rules errors has been a longstanding issue with many users – hopefully this has been improved now, but there will probably be some bugs, so please report if you encounter any.

Changes in the Kosmos console

Kosmos console has a new command called “zappy” which allows you to download OSM data from the OSMXAPI server. This has been already available in Kosmos GUI, but I wanted to extend it to command line support since it can be used for automating certain tasks. A simple example: you can now periodically download new OSM data for a certain area and generate fresh tiles from this data – so your tile server will offer up-to-date maps.

By the way, the command line options for generating and serving tiles have been changed. Instead of having to manually edit parameters in the Kosmos project file, you can now specify everything you need from the command line. Also, these parameters will be stored in a special file together with generated tiles, so when serving tiles, you only need to specify the location of the tiles cache. I’ll write more about this on the OSM Wiki later. UPDATE: the instructions have been updated.

Exporting georeferenced bitmaps with world files

All bitmaps generated in Kosmos (except the tiles) are now equipped with a world file, which should allow users to use these bitmaps in other GIS tools. However, this is only a partial solution – you still cannot import bitmaps into Kosmos and also GeoTIFFs are not supported. I will implement importing of bitmaps with world files in later versions, but only if they use Transverse Mercator projection. Supporting other types of projections (by using image rectification) is not planned in the near future since it’s beyond the scope of this application (read: I just don’t have enough time to do it).

NOTE/WARNING: you will not be able to open bitmaps from projects created with previous versions of Kosmos, since the new version does not use the georef information embedded in the project file – it now uses world files for this. Unfortunately backward compatibility is one of the things I chose to sacrifice due to lack of time – mostly because I think all the bitmaps generated in Kosmos can be regenerated without much problems.

Other new stuff in brief

  • Generating relief contours in GUI is now customizable – you can specify the elevation interval. I also wanted to add customization of how the contours are rendered, but this will have to wait for the next release.
  • Kosmos can now read GPX v1.0 files
  • Entering of direct OSM wiki URLs for rendering rules (like is now allowed.
  • Data files that cannot be loaded in the GUI project are now greyed-out.
  • The same way can now appear in multiple multipolygons without causing Kosmos to crash.
  • Various bug fixes.

That’s it – the next task is to update the Kosmos documentation in the OSM Wiki. After that, I’ll try to get back on Kosmos 3D stuff which I neglected for the past few months.

I hope you enjoy the new version and please report any bugs you discover (there’s bound to be a few of them ;) ).

Published by breki on 18 Jul 2008

Kosmos 2.1

New version of Kosmos is here. Since I’ve neglected the rendering engine during the implementation of 2.0 release, I decided to do most of the work for this release on improving the rendering.

You can download the 2.1 version from the standard place:

UPDATE (July 19th): I discovered a small bug in the new release – generated contours were not shown on the map. This has been fixed now, please download a new package.

So what has been improved?


Kosmos can now render relations. I’ve added a sample rule in general purpose rules Wiki page for rendering cycle routes:

Rule Name Targets Selector Template Options Comment
RouteCycle relation type=route route=bicycle Polyline (MinZoom=7, Color=#50FF0718, Width=7:1;17:18, Curved=true)

will produce a pinkish half-transparent cycle route:


Note that rules ignore roles of members in a relation – currently I don’t see how the roles could be incorporated into the rendering rules.

Text Rendering

There is a new TextMode called WayCenter which draws the text (roughly) in the center of a way:


There are also two new parameters which enable rendering of outlined text: OutlineColor and OutlineWidth, example (sorry for the odd formatting):

PlaceTown node place=town Text (MinZoom=10, MaxZoom=15, Color=black, TagToUse=name, FontName=Trebuchet MS, FontStyle=bold, FontSize=10:10;17:25, OutlineColor=white, OutlineWidth=20%)

will produce something like this:


Kosmos now knows how to wrap labels:


The wrapping is done using the “Text label wrap factor” preferences setting. It is a ratio of (roughly) maximum line length compared to the line height. Normal values are somewhere from 4 to 10, I guess.

Map Scale Indicator

… is now shown on the map:


You can turn it off. You can also switch from metric to U.S. Customary units in Preferences dialog (“Use metric units“).

Rendering Engine Speed-Up

I’ve refactored quite a large piece of rendering engine code to increase the rendering speed and lower the memory consumption. Basically, in previous versions each rendered map element had all its settings (color name, width, …) stored by itself. Now the settings shared by multiple elements are stored in one place (a “style”). This also allows caching of GDI+ objects for each style without the need to recreate them for each map element.

There are also a number of bugfixes in this release (basically every bug that was reported has been fixed).

Source Code

I’ve also published the sources here: . I’ll prepare a special Wiki page with some information about the source code and what one can and what one cannot expect from it. So please be patient before starting to send me hate notes about not being able to compile the source code ;)

Published by breki on 07 Jul 2008

Kosmos 2.0 Is Here At Last

After almost 5 months of development, I can now announce that I’ve just released a new version of Kosmos. I’ve talked about it several times, although my blog posts have been reduced to practically zero – I’ve been so busy with Kosmos that I just didn’t find the time to write.

NOTE: before proceeding I should warn you that I consider this release to be in beta stage. I spent the last month killing bugs in Kosmos, but since a lot of new functionality was added there are bound to be quite a few bugs still lurking around. If/when you encounter them, please report them on the Kosmos OSM Wiki talk page.


You can download the latest version from here. I’ll be also publishing the source code in the next few days.

So what’s new?

Tabbed Document Interface

First of all, the GUI interface has been completely rewritten. Kosmos GUI now uses an tabbed document interface (TDI):


As you can see from the screenshot, the user interface is somewhat reminiscent of Visual Studio. You have a Project Explorer through which you can edit the project file. There is the Properties window which displays properties of the currently selected project or data file. There is also the Activity Logger window which shows the activity Kosmos is performing.

Of course, there is the Map window with the familiar Kosmos-rendered OSM map. You can also look for new maps using the Web Map window which is able to display most common Web maps (OSM, Google, Yahoo, Microsoft).

Downloading OSM Data

Kosmos can now download the OSM map data from the OSMXAPI server. So in theory you can now generate a map without any additional tools. Be warned though: OSMXAPI can be quite slow sometimes, especially if you choose to download large map areas.

GPX Support

Kosmos now has the ability to download GPS data from a GPS unit and display it on the map. You just need to have gpsbabel software downloaded and saved somewhere on the disk.

Relief Contours

I integrated the Srtm2Osm tool into Kosmos GUI so that users can generate relief contours for any map area:


Imagery From Landsat And

Another nice feature in Kosmos 2.0 is the ability to download free satellite imagery from Landsat and sites:


Tile Server

The tile server (launched from the Kosmos Console) is now able to render all of the data specified in the project file. This means that you can now render tiles which contain shaded reliefs, satellite imagery, GPX tracks, elevation contours.

Other Stuff

There are lot of other improvements which I will describe on the Kosmos OSM Wiki pages in the next days.

What’s Missing

This is not the end of Kosmos development, far from it. I still have quite a few ideas I want to introduce into Kosmos. I realize that a lot of things are still missing – I have a “to do” list that is growing day by day. Hopefully future releases will have even more cool features. So be patient… And do send me some feedback, critiques and ideas :)