Newby asking for help

Topics: Data Access, General Topics, SharpMap Project, SharpMap v2.0, WinForms Controls
Feb 7, 2012 at 3:34 PM

Hi guys,

I've created some tiles of a region in germany. All are saved as png files with heigthxwidt = 256x256px.

Now I'm trying to load them via Brutile. They should be shown on a picturebox.

tiles\1\0 - 2 pics (north west, south west of the region)

tiles\1\1 - 2 pics (noth east, south east of the region)

tiles\2\0 - 3 pics

tiles\2\1  - 3 pics

tiles\2\2   - 3 pics

tiles\2\3   - 3 pics

and so on. Every subdirectory of tiles includes another zoom level.

Can anybody explain to me how i can load for example the file from tiles\1\... to the picturebox?

I tried it like this.

const string DATA_PATH = @"D:/myfiles/Dokumente/Bachelorarbeit/code_und_co/tiles/";

FileTileProvider ftp = new FileTileProvider(new BruTile.Cache.FileCache(DATA_PATH, "png"));


and add it to a SharpMap

_sharpMap = new SharpMap.Map(new Size(600, 300));

_sharpMap.BackColor = Color.Transparent;            

ITileSource tileSource = new TileSource(ftp, new BruTile.PreDefined.SphericalMercatorInvertedWorldSchema());

TileLayer tL = new TileLayer(tileSource, "TestLayer");



picMap.Image = _sharpMap.GetMap();


I'm new at both thematics (sharpmap and brutile) so it would be nice if anybody could help. 

I was searching at and other discussions before, but can't find an entry for me to get it working.

Feb 27, 2012 at 2:27 PM
Edited Feb 27, 2012 at 6:06 PM

hi guys,


i've solved the  Problem 


If anyone has similar problem. The code is used, could be found here at the brutile forum

Feb 27, 2012 at 6:06 PM
Edited Feb 27, 2012 at 6:08 PM


As described on the link above I've tried to paint a polygon like this

SharpGeometries.LinearRing lr = new SharpGeometries.LinearRing(pointArray);                       
SharpGeometries.Polygon poly = new SharpGeometries.Polygon();                
poly.ExteriorRing = lr;


The Ring is a closed one (IsRing is true). THE PROBLEM IS THAT I CAN'T SEE IT AFTER PAINTING.


If I use the same pointArray and Create a LineString it works without any problems and I can see that the painted LineString results in Closed Ring


SharpGeometries.LineString ls = new SharpGeometries.LineString(pointArray);                              


Values of the LinearRing:

EndPoint {POINT (10.96406 51.85224)} SharpMap.Geometries.Point

StartPoint {POINT (10.96406 51.85224)} SharpMap.Geometries.Point


[0]	{POINT (10.96406 51.85224)}	SharpMap.Geometries.Point
[1]	{POINT (10.93637 51.83149)}	SharpMap.Geometries.Point
[2]	{POINT (10.93186 51.8244)}	SharpMap.Geometries.Point
[3]	{POINT (10.92811 51.80885)}	SharpMap.Geometries.Point
[4]	{POINT (10.92836 51.80831)}	SharpMap.Geometries.Point
[5]	{POINT (10.93987 51.79237)}	SharpMap.Geometries.Point
[6]	{POINT (10.94113 51.79187)}	SharpMap.Geometries.Point
[7]	{POINT (10.94192 51.79172)}	SharpMap.Geometries.Point
[8]	{POINT (10.94274 51.79164)}	SharpMap.Geometries.Point
[9]	{POINT (10.95442 51.79065)}	SharpMap.Geometries.Point
[10]	{POINT (10.95515 51.79059)}	SharpMap.Geometries.Point
[11]	{POINT (10.97929 51.79452)}	SharpMap.Geometries.Point
[12]	{POINT (10.98687 51.79607)}	SharpMap.Geometries.Point
[13]	{POINT (10.99739 51.80222)}	SharpMap.Geometries.Point
[14]	{POINT (10.99782 51.8037)}	SharpMap.Geometries.Point
[15]	{POINT (10.99788 51.80406)}	SharpMap.Geometries.Point
[16]	{POINT (10.96406 51.85224)}	SharpMap.Geometries.Point

Both figures are used as GeometryProvider


ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory ctfac = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
var gp = new SharpMap.Data.Providers.GeometryProvider(ls);
//var gp = new SharpMap.Data.Providers.GeometryProvider(poly);
VectorLayer vl = new VectorLayer(layerName);
vl.CoordinateTransformation = ctfac.CreateFromCoordinateSystems(EPSG4326, EPSG900913);
vl.DataSource = gp;
Color col = Color.FromArgb(10, Color.Aqua);
vl.Style.Fill = new SolidBrush(col);


Does anybody has an idea why the polygon can't be painted???

Feb 28, 2012 at 1:26 PM

Not sure what it is?

After you assigned vl.Style.Fill, does it have a value?

If you leave out assigning the CoordinateTransformation, does the polygon appear?

What happens if you zoom like this: sharpMapImage.Map.ZoomToBox(gp.GetExtents())?

The best thing is probably you set a breakpoint in the VectorLayer.Render method and see what happens.

Hth FObermaier

Feb 28, 2012 at 4:48 PM

Hey FObermaier,

thanks for your reply.

I don't know what is changed but now it works. 

Maybe visualstudio was annoying me. I had to reboot before some minutes and ... voila it works.