Kosmos/Tile Map Server

From OpenStreetMap Wiki
Jump to navigation Jump to search

Kosmos Console offers tools to generate map tiles from a project file and then run a simple integrated web server to show those tiles. It uses the same javascript code the OpenStreetMap slippymap is using).

NOTE:: currently there are some problems with the integrated Web server - sometimes the tiles are not shown properly. I'll try to fix this. I am also thinking about providing extra files for running the tile map server through IIS. If anybody is interested in providing support for other types of web servers, it would be great,

The description below uses the "Isle of Wight" project file which comes bundled with the Kosmos. If you want to run the tile map server for other projects, simply replace the reference.

NOTE: the description has been updated to the version 2.2 of Kosmos - there were some changes in the way the tile generating and serving is done.

Generating Map Tiles

You first need to generate map tiles. This is done using the tilegen command:

Kosmos.Console.exe tilegen "..\Samples\Isle of Wight\Isle of Wight.kpr" 50.5 -1.75 51 -1 0 17 -ts Tiles

This command will generate tiles for the sample project, from the zoom level 0 to the zoom level 17. The tiles will be stored in the Tiles subdirectory.

This is a sample output of the Kosmos Console:

Loading the project file...
Loading project file... (0%)...
Loading rules... (5%)...
Loading rendering rules...
Loading data file(s)...
Loading data file 'osmxapi_20080706_213852.osm'... (5%)...
Loading data file 'ShadedRelief_20080706_213941.png'... (31%)...
Loading data file 'ElevationContours_20080706_213955.dat'... (58%)...
Started rendering tiles for zoom level 0.
Started rendering tiles for zoom level 1.
Started rendering tiles for zoom level 2.
Started rendering tiles for zoom level 3.
Started rendering tiles for zoom level 4.
Started rendering tiles for zoom level 5.
Started rendering tiles for zoom level 6.
Started rendering tiles for zoom level 7.
Started rendering tiles for zoom level 8.
Started rendering tiles for zoom level 9.
Started rendering tiles for zoom level 10.
Started rendering tiles for zoom level 11.
Started rendering tiles for zoom level 12.
Started rendering tiles for zoom level 13.
...

Running The Web Map Server

After you've created tiles, you can start the web server using the tileserv command:

Kosmos.Console.exe tileserv Tiles http://localhost/Kosmos/

Now you can go to your browser and go to URL http://localhost/Kosmos/ and you should see a slippymap with the sample map (you may need to zoom into the map to see the results - I'll fix this for the next release).

NOTE: You can of course generate tiles even while running the HTTP server, just open a separate command line console. Some browsers may need refreshing of page to detect new versions of tiles.