render map in tiled mode like google or bing map

Topics: Web Controls
Oct 1, 2010 at 9:31 AM

hello guys,
i am making a map service that its engine is sharpmap.i read .shp files and display a map,but my service is very slow and i want to display maps like google or bing very fast and render in tile mode to load fast.how can i do it?
thanks very much

Developer
Oct 1, 2010 at 3:35 PM
Edited Oct 1, 2010 at 3:44 PM

Hi there,

There is no such tool as part of SharpMap yet. I worked in some projects where on the server side they used tilecache.py (python) and geowebcache (java). These tools request the tiles from a WMS and store them locally and serve the tiles upon incoming request strings. You could try to use those tools.

Alternatively, it is not very hard to build something like that in c# - if you keep it simple. You have to publish your Shapefiles using the WMS in SharpMap. Then you need to make a asmx that takes TMS request as argument. You need to parse that into a BruTile.TileIndex then you can use the BruTile dll to query the WMS according to the tile schema you defined. Store the tile into BruTile's TileCache and return it to the client . On the next request directly return the cached tile.  

Paul

Dec 14, 2010 at 10:38 AM
pauldendulk wrote:

Hi there,

There is no such tool as part of SharpMap yet. I worked in some projects where on the server side they used tilecache.py (python) and geowebcache (java). These tools request the tiles from a WMS and store them locally and serve the tiles upon incoming request strings. You could try to use those tools.

Alternatively, it is not very hard to build something like that in c# - if you keep it simple. You have to publish your Shapefiles using the WMS in SharpMap. Then you need to make a asmx that takes TMS request as argument. You need to parse that into a BruTile.TileIndex then you can use the BruTile dll to query the WMS according to the tile schema you defined. Store the tile into BruTile's TileCache and return it to the client . On the next request directly return the cached tile.  

Paul

 

Any Example??  in this way you are building up the tile on demand...  correct??  

There is any code to parse this TMS Request into Bru Tile Tile index?  

Thanks

Alberto

Editor
Dec 14, 2010 at 1:44 PM

Hi!

There are two steps you need to work out:

1. Build a tile repository. You can use SharpMap or other tools to build a repository of tiles with a spatial index in db. Create a service that lets you query and provide the tiles (based on geo location or even simply your own index).

2. Create a MapsUI tile provider and use MapsUI to display the map.

What specific problems are you having with building those?

Goran

Dec 14, 2010 at 2:02 PM

What i would like to do is this:

i would like to create a repository of tiles like the one of Open Street Map at : http://a.tile.openstreetmap.org

 

Then i would like to use Bru Tile Layer as "Client" of this repository using a BruTileLayer and the FileTileProvider as source?

look @ that thread.....

http://brutile.codeplex.com/Thread/View.aspx?ThreadId=77092

 

 

The problem is...   i've all my data (a lot!) in my sql 2008 server i would like to pre render Tiles..... for a list of specific zoom levels.....

Editor
Dec 14, 2010 at 4:28 PM

Ok.

So step one would be to make a tile renderer app. Something capable of positioning SharpMap at chosen locations (and specified width and height) and then rendering the map to file. This way you create tiles.

Something like:

---------------------------

//create a map of the size of your tiles

var map = new SharpMap.Map(new Size(tileSize, tileSize));

//add layersm providers etc...

//then loop through world coordinates at intervals of your tileSize calling

map.Center = new SharpMap.Geometries.Point(centerX, centerY);

var bitmap = (Bitmap)map.GetMap();

//save bitmap to disc

//save spatial coordinates and filename to db

---------------------------

Once you've done that you can either repeat the procedure at various zoom levels or simply join up images yourself (use 4 images to create 1 image at the higher zoom level).

I suggest you use distinct directories for each layer and transparent background. This way you can later join up various layers.

Also think about using a naming scheme that will spread the tiles into various subdirectories so you avoid problems with having one large directory of images.

Then it is a simple matter of creating a service that will return requested images at certain coordinates. To simplify matters I'm using my own coordinate system for the tiles (so 0,0,0 is the first tile on the first zoom level. The service then uses db to find the file (or perhaps use the same naming scheme used by the generator!) and returns an image. The final step is to make a MapsUI tile provider that will call this service...

Goran

Dec 15, 2010 at 7:52 AM

Ciao goransiska....

after a big googleada and some code and example review...  what i saw and what i would like to use at the end...   in the rendering client is the TileLayer of SharpMap that use BruTile...     It need an ITileSource  that need in the end a ITileProvider and ITileSchema

So...   as ITileProvider i can use the FiletileProvider from BruTile that needs a FileCache object....   what i saw is that internally in the end a FileCache take a TileIndex and the associated bitmap...     so...     it should be enought if i create scripot that gived a TileSchema it render tiles images for each TileIndex i need and store thrue the FileCache into disk....    in this way    later i can use again this pre-rendered images thrue the TileLayer giving the same TileSchema.... and the same path for the FileCache!!     

.....i have to investigate yet if given a TileSchema i can obtain the entire TileIndex list fore each zoom level i want to render... ;)  but i hope yes!!! 

 

Thanks

Alberto

 

Coordinator
Jan 2, 2012 at 9:51 AM

Maybe one can use the CreateTileLayer sample by trievy as a starting point:

http://sharpmap.codeplex.com/SourceControl/changeset/view/95025#1873797

It is incorporated in the WinFormSamples project.

Hth FObermaier