SharpMap v2.0 porting to .NET CF project

Topics: CompactFramework, SharpMap v2.0
Sep 17, 2007 at 12:15 AM

I've been working with SharpMap for some time, trying to use it on the .Net Compact Framework for the Pocket PC. Many improvements have been made to the upcoming version, while the PPC version was based on an older one of SharpMap.

As it seems to be some interest on the matter i've created a project at Google Code called "sharpmapcf"

The main purpose is porting SharpMap v2.0 to CF. It's in the very beginning, but i hope it will grow and will (hopefully) support writting shape files. Any help will be welcomed.

Best regards,
Javier Tellez
Sep 17, 2007 at 7:19 AM
I'll take a look as soon as possible :)
Sep 17, 2007 at 1:09 PM

Another one who try to port SharpMap! Maybe we can make only one discussion about Compact Framework and Sharpmap.
Sep 17, 2007 at 4:40 PM
Hi Javier -

I looked at the code in the Google Projects site, and it isn't v2.0 of SharpMap. Did you get it from CodePlex or from Google Projects?
Sep 18, 2007 at 12:56 PM
Edited Sep 18, 2007 at 1:07 PM
Hi codekaizen.

The code is taken from the Trunk of the repository at CodePlex (lattest revision on Sep 3 at 11:59 PM by Volleyknaller) as a first try, because the version i'm using now for the PPC (that works) is based on an even older version of SharpMap.

It's on the Wiki, but i have not deleted the original code, just commented out what's not supported by the CF. What's been removed are Oracle.cs and SqlLite.cs from the Providers, Surrogates.cs from Utilities, OleDbPoint.cs from Data/Providers, and HttpHandler.cs, WmsException.cs, WmsServer.cs from SharpMap.Web namespace.

Maybe i've announced the project too soon, sorry for that.

The wiki is not very clear yet, but i know that everithing not documented is lost, so it seems a bit confusing by now. Well, something similar to what was said at a Open Source conference last year: "What is not shared is lost" :)

Best regards,
Javier Téllez
Sep 19, 2007 at 12:14 AM
Ok, but over on the SharpMap Compact Framework version thread, you wanted to start with v2.0... so perhaps I'm just confused about what is at
Sep 19, 2007 at 11:35 AM
I admit it's been confusing. It will contain SharpMapV2 as in, that i guess it's almost done.

What i don't know exactly is the way of conducting the port. If it's better not including classes with unsupported functionality (oracle, web server, ...) or include them all and marked somehow as not supported.

Sep 19, 2007 at 12:36 PM

codekaizen wrote: so perhaps I'm just confused about what is at

Me too. In any i think that to create a separate project for SharpMap CF isn't a good approach: i suppose that the best way is to create a separate project INTO SharpMap, that references the same code, that compiles both the desktop and the mobile version using conditional compilation symbols... what do you think, it's a practicable way?
In any case could be useful as a repository for test the porting without broken sharpmap in any way.
Sep 19, 2007 at 12:37 PM

codekaizen wrote: so perhaps I'm just confused about what is at

Me too. In any i think that to create a separate project for SharpMap CF isn't a good approach: i suppose that the best way is to create a separate project INTO SharpMap, that references the same code, that compiles both the desktop and the mobile version using conditional compilation symbols... what do you think, it's a practicable way?
In any case could be useful as a repository for test the porting without broken sharpmap in any way.
Sep 19, 2007 at 1:09 PM
D. Guidi.

I'm with you. Make two separated projects is worst to mantain.
Sep 19, 2007 at 7:15 PM
We need to wait for the Beta1, so we could start the works with a semi-stable release.
Then we use as a temporary repo for storing the project, so we could use the code from beta1 and create a ppc project that links directly the original sources: the we work with conditional statements and see what happens... maybe when the beta2 is ready to release, we could join the main project and insert (from scratch) all modifies.
Sep 19, 2007 at 7:48 PM
I concur with D_Guidi - Beta 1 will be a stable point to work from. There has been a lot of thrash until now, but things have been settling down considerably over the past 2 weeks.

I'm just cleaning up a few straggling issues before I branch and post it.
Sep 20, 2007 at 10:39 AM
I agree the best place for the project would be SharpMap, if it becomes something workable. The idea is keeping the original source code and use preprocessing for CF on a separate place until it reaches a good poin. But it also has to be considered that it may become very hard to read.
For example, attributes (ie Serializable) can be commented out, and modified methods can be attached to the original one. But adapting things like the System.ComponentModel.BackgroundWorker in FeatureLayer (for example) are not straightforward.

I'll keep playing with the latest version at while the Beta 1 is ready.

Sep 20, 2007 at 11:53 AM

guillermoTell wrote:
I agree the best place for the project would be SharpMap, if it becomes something workable. The idea is keeping the original source code and use preprocessing for CF on a separate place until it reaches a good poin. But it also has to be considered that it may become very hard to read.

This is true, but it's also true that maintain two separate versions of the code it's very hard: think at the work to do when someone fix a bug in SharpMap... :(
The main problem here is that codekaizen must open the repository to us.

guillermoTell wrote:
For example, attributes (ie Serializable) can be commented out, and modified methods can be attached to the original one. But adapting things like the System.ComponentModel.BackgroundWorker in FeatureLayer (for example) are not straightforward.

I think that we have two issues here:
1) Maybe we need to separate SharpMap code in different projects/assemblies (core,presentation,index,utils,...), so maybe we could rewrite from scratch the projects too hard to port to the CF.
2) We could refactor sharpmap to use a shared project (like SharpMap.Utils) that delegate some operations to an adapter: using the example of Backgroundworker, we could write in this Utils project a CustomBackgroundWorker for SharpMap that extends the .NET 2.0 BackgroundWorker, but for SharpMapCF we could use this component:

As you can see, we need to plan and discuss all the operations to do, so we could start with a study project when Beta1 is released, then we could maintain a document with all the changes needed, that then we discuss with SharpMap developers...
Too much work? I hope not ;)

Sep 20, 2007 at 1:29 PM
Hi guillermoTell. Here is an alternative BackgroundWorker for CF, I think I found it on CodeProject or similar - not sure who translated it.. Hope it is of use to someone..
My personal preferance would be conditional compilation to cover desktop+server/CF/(Silverlight??).
I'm playing around with with the v2 drops... so much potential.. cant wait for the beta.. JD

using System;
using System.Collections.Generic;
using System.Text;

//translation from Daniel Moths implementation of the BackgroundWorker class
//available in .NET 2 but not in the compact framework

namespace System.ComponentModel
#region "EventArgs classes"

#region "background worker"

public class BackgroundWorker
: ComponentModel.Component
public event DoWorkEventHandler DoWork;
public event ProgressChangedEventHandler ProgressChanged;
public event RunWorkerCompletedEventHandler RunWorkerCompleted;

public BackgroundWorker():this(new Windows.Forms.Control())

public BackgroundWorker(Windows.Forms.Control aControl)
mGuiMarshaller = aControl;

public bool CancellationPending
return mCancelPending;

public void ReportProgress(Int32 aProgressPercent)
this.ReportProgress(aProgressPercent, null);

public void ReportProgress(Int32 aProgressPercent, object aUserState)
throw new InvalidOperationException("doesn\'t do progress events. Ypu must use WorkerReportsProgress = true");
Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ProgressHelper), new ProgressChangedEventArgs(aProgressPercent , aUserState));
public void RunWorkerAsync()
public void RunWorkerAsync(object aArgument)
throw new InvalidOperationException("Already in use");
if(DoWork == null)
throw new InvalidOperationException("you must subscribe to the DoWorkEvent");

mInUse = true;
mCancelPending = false;

Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(DoTheRealWork), aArgument);

public void CancelAsync()
throw new InvalidOperationException("Doesn't support cancel, You must use WorkerSupportsCancellation=true");
mCancelPending = true;

public bool WorkerReportsProgress
return mDoesProgress;
mDoesProgress = value;

public bool WorkerSupportsCancellation
return mDoesCancel;
mDoesCancel = value;

public bool InProgress
return mInUse;

#region "fields"
private bool mInUse;
private bool mCancelPending;
private bool mDoesCancel;
private bool mDoesProgress;
private RunWorkerCompletedEventArgs mFinalResult;
private ProgressChangedEventArgs mProgressArgs;
private Windows.Forms.Control mGuiMarshaller;

#region "private methods"

private void ProgressHelper(object o)
mProgressArgs = o as ProgressChangedEventArgs;
mGuiMarshaller.Invoke(new EventHandler(TellThemOnGuiProgress));

private void TellThemOnGuiProgress(object sender, EventArgs e)
this.ProgressChanged(this, mProgressArgs);

private void DoTheRealWork(object o)
Exception er = null;
bool ca = false;
object result = null;

DoWorkEventArgs inOut = new DoWorkEventArgs(o);
this.DoWork(this, inOut);
result = inOut.Result;
catch(Exception ex)
er = ex;

RunWorkerCompletedEventArgs tempResult = new RunWorkerCompletedEventArgs(result, er, ca);
Threading.ThreadPool.QueueUserWorkItem(new Threading.WaitCallback(RealWorkHelper), tempResult);
mInUse = false;
mCancelPending = false;

private void RealWorkHelper(object o)
mFinalResult =o as RunWorkerCompletedEventArgs;
mGuiMarshaller.Invoke(new EventHandler(TellThemOnGuiCompleted));

private void TellThemOnGuiCompleted(object sender, EventArgs e)
this.RunWorkerCompleted(this, mFinalResult);




public class RunWorkerCompletedEventArgs
: EventArgs
private readonly object mResult;
private readonly bool mCancelled;
private readonly Exception mError;

public RunWorkerCompletedEventArgs(object aResult, Exception aError, bool aCancelled)
mResult = aResult;
mCancelled = aCancelled;
mError = aError;

public Object Result
return mResult;

public bool Cancelled
return mCancelled;
public Exception Error
return mError;

public class ProgressChangedEventArgs
: EventArgs
private readonly int mProgressPercent;
private readonly object mUserState;
public ProgressChangedEventArgs(Int32 aProgressPercent, object aUserState)
mProgressPercent = aProgressPercent;
mUserState = aUserState;

public Int32 ProgressPercentage
return mProgressPercent;
public object UserState
return mUserState;

public class DoWorkEventArgs
: ComponentModel.CancelEventArgs
private readonly object mArgument;
private object mResult;
public DoWorkEventArgs(object aArgument)
mArgument = aArgument;
public object Argument
return mArgument;
public object Result
return mResult;
mResult = value;


#region "delegates for 3 events of class"

public delegate void DoWorkEventHandler(object sender, DoWorkEventArgs e);
public delegate void ProgressChangedEventHandler(object sender, ProgressChangedEventArgs e);
public delegate void RunWorkerCompletedEventHandler(object sender, RunWorkerCompletedEventArgs e);

Sep 20, 2007 at 6:43 PM
Edited Sep 21, 2007 at 8:06 PM
Hey guys,

I really like where this thread is going... let me see if I can help things progress a bit.

  • For the compilation conditionals vs. refactoring, I think it would be better to choose refactoring over conditionals, where possible. The reasons for this are that one it relies on key advantages of object oriented programming - encapsulation and polymorphism, and, becuase of this, makes the code base easier to maintain and more robust. To extend Diego's example, we can author a custom background worker class which has an abstract implementation. On the full framework, we can use BackgroundWorker under the covers, and on the CF we can use the async pattern. Later, when we want to allow SharpMap to scale up on web servers, we can use another implementation which doesn't use BackgroundWorker, since it uses the same thread pool which Asp.Net uses to service requests. Trying to manage this with objects is easy, natural and well-understood - you are just swapping classes with different implementations and behavior. Trying to do this with conditional compilation results in something that is arbitrary and hard to learn and harder to enforce a consistant usage: which conditionals do we use, where and how often? The decisions have to be arbitrary (there are no principles and patterns to guide them); the code becomes brittle and quality declines. But conditionals can be useful. We could implement a SerializableAttribute which would allow us to perform serialization on CF (or at least just get the code to compile). This class could be conditionally compiled for CF, since the full framework has System.Runtime.Serialization.SerializableAttribute, which doesn't allow itself to be replaced: to get attribute-based serialization you have to use the framework implementation.

  • As for the repository access, Diego, I'm hoping we can move it over to CodePlex very soon. I'm reluctant to do it until they release SvnBridge as a server-side solution, but I could be persuaded to make the jump after Beta 1 regardless, if you wouldn't mind running SvnBridge on your client.
Sep 20, 2007 at 8:19 PM

codekaizen wrote:
  • As for the repository access, Diego, I'm hoping we can move it over to CodePlex very soon. I'm reluctant to do it until they release SvnBridge as a server-side solution, but I could be persuaded to make the jump after Beta 1 regardless, if you wouldn't mind running SvnBridge on your client.

I've never tried the SvnBridge, but i think that we could try to use it, instead of force you to jump to codeplex.
Personally I love SVN (although ankhsvn it's not a perfect tool) and I hate TFS&CodePlex, so i hope you could continue to leave SharpMap @GoogleCode.
Sep 20, 2007 at 8:28 PM
SvnBridge works pretty well, and I know that the CodePlex folks will be hosting it soon on the CodePlex server, so the SVN experience will be identical to Google Code. When you run SvnBridge locally, you almost get the same experience (just have to remember to start it).
Sep 21, 2007 at 7:36 PM
Thanks for both BackgroundWorker workarounds.

If a port to CF wants to live up to date with the changes in the dad version, refactoring, factory classes, is a better approach, but with no doubt more complicated.

Anyway, just 221 errors until the BackgroundWorker issue and now 237, till the next batch.

I'm keeping in the wiki a log with the errors, where the problem is and a possible solution. As there are so many, i guess the better is resolving them at first in the easy way (#if #else #endif). When it compiles, we'll try to make it work.

Sep 23, 2007 at 9:50 PM
Hey guillermo -

I'm ditching background worker and just going with the Async pattern (BeginExecuteIntersectionQuery and EndExecuteIntersectionQuery, etc.) on the data source. This will give the same layer usage scenario as well as support scenarios which use the data sources of SharpMap directly, as well as make support for CF easier. Sorry about the change. Once Beta 1 drops, this kind of thrashing will be much lower.
Sep 24, 2007 at 10:55 AM
Edited Sep 24, 2007 at 1:22 PM
Thanks for saying codekaizen.

I'm now stalled with the Reflection.Emit namespace (DynamicMethod) in FeatureDataXXX and FeatureMerger classes. Had never used it.

For example, in FeatureDataRow, can i make this?

static FeatureDataRow(){
#if !CFBuild


_getColumns = (GetColumnsDelegate)getColumnsMethod.CreateDelegate(typeof(GetColumnsDelegate));

_getColumns = GetColumnsInvoker;


And adding this method for CF:

static DataColumnCollection GetColumnsInvoker(DataRow row)
FieldInfo columnsField = typeof(DataRow).GetField("_columns",
BindingFlags.NonPublic | BindingFlags.Instance);

DataColumnCollection colCollection = (DataColumnCollection)columnsField.GetValue(row);

return colCollection;
Oct 17, 2007 at 5:03 PM
Hello all,

I would like to know how is this porting going? Is there any news? Any version that compiles?
I don't know if I can give much of a contribution, but certainly can test and help find bugs...

Please let me know any news on this interesting project...

Oct 18, 2007 at 2:10 AM
Hey @guillermoTell...

Sorry I didn't see your post on Sept. 23...

DynamicMethod is used to provide a much faster call than Reflection allows. It is about 9x faster than a FieldInfo.GetValue call. It's too bad that CF doesn't support it. Not using it will make the code much slower, since it is often on a critical codepath.

Perhaps it would be better to just rewrite the FeatureDataSet / FeatureDataTable for CF?
Nov 6, 2007 at 2:33 PM
Maybe this could help: Using GDI+ on Windows Mobile
Nov 30, 2007 at 5:26 AM

Where I can download the compact framework version?

Jan 21, 2008 at 1:33 PM

I haven't found the compact framework version of sharpmap, or the code that people are working on it. Where is that code?

I'm going to work with directX to make a better rendering of the map.

Mar 3, 2008 at 7:00 AM
I am ready to join the CF port. I currently have a real user request to get this going.

One little question (I feel like a dummy, please forgive me)

I am using Visual Studio 2005; where is the place to set the CFBuild variable?


Mar 3, 2008 at 8:32 AM

As much I Know the only version of sharpmap for compact framework is an old dated porting from Pocket Terra. I was posting questions about who are working on the compact framework version but none aswnered me.

You must define the CFBuild in the properties of the project., tab General, configuration Release. The Debug configuration and the Release must have the same conditional configuration symbols.

Are you working on a comercial version of Sharpmap? I don't understand this: I currently have a real user request to get this going

See you!
Mar 3, 2008 at 10:24 AM
Did you try the google code project that started the thread? I don't know what its status, the last checkin is from oktober 2007.

The wiki contains some info on the porting problems:

What we prefer is to build the CF version from the normal code using some ifdefs, but that may not be that easy. Maybe the best approach for you is to create your own stripped down project where you port only those things you really need for your client. If you document the changes you need to make we could use that for a future CF version.
Mar 3, 2008 at 10:41 AM
Hello Vans and Paul,

Ofcourse I am not working on a commercial version of SharpMap. I am an OpenSource addict, no way I am going to close the source on such a wonderfull project! I would not find that appropriate.

No, I have a customer that is willing to pay me for spending time in getting this working on CF. Not directly, but using SharpMap as a renderer would make their wishes benefit from work already done. Of course any results booked will be returned to a general available SharpMap CF.

I looked at the google project, but it seems to have no activity.

My progress this far:
- Created a new C# Compact framework solution in Visual Studio
- Created a project that will become a CF Form demo
- Created a C# CF Class library project that is basically a wrapper for the existing Sharpmap project:
-- Copied the directory structure for the Sharpmap project
-- Added linked items for all the files currently existing in the Sharpmap project directory
-- Setting up de #if !CFbuild and #elif CFBuild conditional symbols
-- Currently I am working on PointF -> Point conditionals and Serialization
- Saved my changes
- Tested that the regular SharpMap still compiles, it does.
- Continuing setting up conditional symbols

Anyone interested, feel free to help.
- I copied the directory structure from the shar
Mar 3, 2008 at 1:24 PM
Hello millo and Paul,

My fear is if there are more people working on anothers ports of SharpMap, so we can make the work that they did before or we are working on the same things.
Mar 3, 2008 at 2:51 PM
Hello VansFannel,

I share your concern, that is why I contacted GuillermoTell to let me join his Google Group and see if we can get synergy.

Hopefully I will hear from him soon.
Mar 3, 2008 at 4:22 PM
Hello milo,

When I started the thread, Guillermo Tell started this thread.

I've been asking for a long time to merge this threads and coordinate the development of that version but none answer me.

@codekaizen maybe can coordinate this porting.
Mar 4, 2008 at 2:01 AM
Question. is the CF "branch" to adding support to server to CF clients or to geneate and server maps from a CF host ?
Mar 4, 2008 at 5:47 AM
Not to ruin your great effort, but just a heads up... this is just not going to perform very well.
SharpMap relies heavily on floating-point precision calculations, something that pocket pc's are terrible at.
Most commercial products use solely integer-based approached, but changing that in SharpMap would be a significant (if not impossible) amount of work.
Mar 4, 2008 at 6:20 AM
Edited Mar 4, 2008 at 6:27 AM
@Odegaard -

Not in v2.0.

In v2.0, the coordinate model is already separated from the calculation engine. Doubles can be converted to an integer or fixed point grid and calculation can be run on it. NTS and JTS already have support for this using a snap rounding algorithm.

Edit: well, it will still be a good deal of work, but the really tortuous stuff is already done.
Mar 4, 2008 at 7:27 AM
Thanks codekaizen, for clearing up that matter.

- One thing that is clear is that it might be best to set v2.0 as a starting point.
- CF as a host for maps sounds a bit over the top, I am mainly looking at getting a map displayed from a variety of GIS sources (and maybe even webservices) with zoom and pan functionality
- Besides GIS data, I have a tileset of OpenStreetMap data that also need to be displayed in the same map.

That's my first goal for now. I am not afraid of a "good deal of work" building an mapviewer from scratch would be even more work and I would really like to see SharpMap become freely available so more wonderfull maps can become available on CF.

I must say that I appreciate the fact that a discussion started going again, this gives me good hope that I can lean on your development knowledge when it becomes necessary. Thanks all for replying!

Mar 4, 2008 at 8:15 AM

Thanks for clearing up this mess.

I have a question for you: I'm going to port Sharpmap v.2.0 to Compact Framework. How can I do? I must make another branch or I must use conditional in code.

It will be interesting to have a 'place' to put all of the problems/solutions that we find. This place can be use to coordinate effors. It's an idea.

Thank you very much!
Mar 4, 2008 at 9:32 AM

The way I am doing it right now:
- Create a new solution
- Create a CF application Project for testing
- Create a CF Class library as a wrapper for SharpMap
- Add "conditional compilation symbols: CFBuild" through Project->Properties->Build
- Create a CF Class library as a wrapper for SharpMap.UI
- Copy the directory structure from SharpMap (by hand, some work, but ok)
- Add Existing items for all the files in SharpMap; use link, NOT copy

- Use conditional statements #if !CFBuild #elif CFBuild #endif

Vans, can we please join forces? It would be a shame if we had to do all the work double. Can I send you what I have so far?
Mar 4, 2008 at 10:16 AM

This is the way that I was looking for.

Send me if you wish, but we need a repository to put our development and we must separate tasks to avoid do all the work double.
Mar 4, 2008 at 12:07 PM
Is this in v2 already? Try to use v2 if you can.
Mar 4, 2008 at 12:24 PM
Yes, it is in V2.

Currently the position for the code is: <root>\Branches\2.0\SharpMapCF

in this folder there is a subfolder called SharpMap. It contains the directorystructure from SharpMap 2.0 (the sharpmap.dll) and only a couple of files: csproj, csproj.user,suo and sln and of course Asembly Info. The REAL source files are references to <root>\Branches\2.0\

Could anyone please set up a repository for this branch? And give me the ability to handover my changes?
Mar 4, 2008 at 1:32 PM
Edited Mar 4, 2008 at 1:48 PM
At the moment a lot of the related projects have their own repositories.. you can set one up on google code and post a message here letting everyone know where it is..

BTW when did you branch off - there have been a lot of changes since v2 beta1..

cheers jd
Mar 4, 2008 at 2:25 PM
I cpc-ed this morning and am working from that repository download.

I am dying to get in to the current Google project and even asked Guillermo to sign me up, but there has been no response. I don't like setting up a project besides the existing one, so I guess I will wait.
Mar 4, 2008 at 3:00 PM
@milovanderlinden -

I'd just set up another project. In the future, if the other project comes back online, we can merge. Forking like this is very common in open source. Just fork, work, and merge later if needed.
Mar 4, 2008 at 3:23 PM
Also, just in case not everyone is clear; the SharpMap v2.0 repository isn't on CodePlex, it's on Google Code:
Mar 4, 2008 at 4:16 PM
Is it okay if I delete the v2.0 branch from codeplex?
Mar 4, 2008 at 5:24 PM
Any way we can just hide it? We'll want to use it later...
Mar 4, 2008 at 6:06 PM
SharpMapCF v2 is now available on Google Code:

There is currently no working version, so only the branches contain source.

I will download sharpmapv2 from Google code and diff it against my own code. Then I will update SharpMapCF v2 to reflect the latest version SharpMap

Anyone care to join the CF project; send me a note.
Mar 5, 2008 at 5:56 AM
Ey, don't forget me!

I've been working with sharpmap for a long time!

May 13, 2008 at 2:32 PM
Is there any progress in development?

How can I help?

See you!
May 13, 2008 at 4:56 PM

I am interested in the SharpMap v2 CF version, too. Milo and I talked some time ago about a new port, but unfortunately I was not able to contribute that much at the moment.
I am well after all the last changes in SharpMap2 and got the latest version running. For this I ported als GeoAPI, ProjNet, NTS and Npack to CF which worked quite well. I did not commit or test anything. I will find time for this at the end of the week.

Well, I don't know if it is too early for a complete port or if SharpMap V2 is already mature enough. Like I said - I just compiled it for CF, not tested it :)

May 20, 2008 at 3:10 PM

mind_the_gap, did you commit all of this projects?

I'm working on rotate the map (if anyone wants to know).

See you!
May 20, 2008 at 3:28 PM

There is nothing on </tt>

I checkout from but all directories are empty!

Maybe nobody has started the 'porting'.

See you!

May 21, 2008 at 4:21 AM
There is also

Anyone know who is on this project?
May 21, 2008 at 7:23 AM
The code probably ported to CF is in

If you checkout from you will see in code a lot of precompiler conditions like this #if !CFBuild.

milovanderlinden probably do the latest checkin.

May 29, 2008 at 7:36 PM

Did you commit GeoAPI, ProjNet, NTS and Npack CF version?
Jun 2, 2008 at 8:55 AM

No, I did not yet. Hopefully I will find time to do this the current week - at the moment I have absolutely no time and all the time deep into other projects.
I will grap the current versions and try to make an up to date CF version out of it and then commit it.

Currently I found no good way to update ported sources to a newer version - I do all the work again with every new commit :)
Jun 2, 2008 at 11:03 AM

Thanks for your answer.

I've asked you this because I want to implement on SharpMap 2.0 for Compact Framework the map rotation. I don't know if you or someone has do it so I want to modify the latest version of code.

When you commit this changes tell me and I'll checkout the code to make this changes.

See you!
Jun 2, 2008 at 2:14 PM

If you would tell me what would make it easier to do the port, I would try to help out on the SharpMap side so that you don't have to do so much work. What are the things you need to do?
Jun 2, 2008 at 6:52 PM
Hi there,

I managed to upload the port of NPack (18145)  and GeoAPI (18458):
I use assembla since many  of my projects are hosted there and I like the tools and stuff they offer (for free). Moreover - call me paranoid - do I think Google gets too big ;)

Well, I will add sites which document the made changes and problems which I could not solve completly.

@VansFannel: I implemented a basic rotation function some weeks ago in C# based on direct byte manipulation of bitmaps - I don't know if this is something that helps or if you would like to do all this on matrix basis (which could be much more accurate :) ).

@Codekaizen: Like said above, I will document the made changes and problems - if this is done I would be happy to talk about this to you :)

One question I have about sharp map is if there is something like buffering. Currently my partner and me wrote a program which does many things SharpMap does - some others, and some features are missing (that are in SharpMap :)) - so I do have some experiences with mobile gis. One major problem to solve was the rendering time. The "state of the art" (of my solution to this) is that every layer has a buffer which stores the current display coordinates of all its points in an array - one after each other. Another list tell where the specific objects (like polygons, polylines, points) start. With those two lists I am able to draw/refresh relatively quick when repainting, panning, etc. Of course does zooming mean to recalculate those points. Is there something similar in stSharpMap? Or maybe a better approach? I tryed, too, with different renderes like MobileDirectX or OpenGL ES - which worked pretty well but did not make much performance difference to standard GDI - at least not in my basic implementation for them.


Jun 2, 2008 at 7:17 PM

Because there isn't an implementation of System.Drawing.Drawing2D.Matrix in Compact Framework I'm going to implement MapTransform with DirectX. This is a lost functionality that I need for the map.

Thanks for your help!
Jun 3, 2008 at 7:22 AM
I thought NPack is exactly what compensates the missing Drawing2D.Matrix classes, or am I mistaken here? But ok, it should be in the responsibility of the renderer to rotate the map and if rotating via DirectX is faster the DirectX renderer (which should exist I think) should use DirectX for rotating. A GDI renderer on the other hand should make use of NPack since GDI does not support matrices natively on Windows Mobile.
Jun 3, 2008 at 5:25 PM
On more recent versions of NPack, I've taken a bit of a swerve in the mission statement of the project: instead of providing concrete implementations of a Matrix class, I've opted to more of a "Bring your own matrix" philosophy, and just concentrated on the matrix / vector interfaces and the computational engine interfaces while providing a default computation engine for the CLR.

This will allow us to use a given technology's implementation of a matrix (such as a GDI or a DirectX matrix) as the matrix for presentation without having to copy these to the "native" format in the rendering phase. Matrixes, coordinates (vectors), and eventually graphics paths, can be treated as type parameters and the "native" ones can be wrapped in a type which provides the interface contract which SharpMap expects, but without an intermediary object, which will improve performance and decrease memory pressure. The final goal is to have matrixes, coordinates and paths all specified via interface contracts and generic type parameters, so that the maximum efficiency in terms of performance and memory can be achieved: geometries and views will essentially "live" in graphics technology managed memory. Of course, there are pitfalls here to be concerned with, namely poorer memory management and less memory, but that can be dealt with at a presenter-level.

So, yes, it was the role of NPack to provide technology-independent matrix implementations, but is now technology-interdependent mediation of matrix representation and computation.

If this is unclear (which I think it might be, since it is a farily complex set of collaborations), let's start a new thread with the goal of getting a model-view-presenter factored out for CF.
Jun 4, 2008 at 9:46 PM

> "Bring your own matrix" philosophy" / "while providing a default computation engine for the CLR"

This sounds pretty good and could be of benefit for CF versions as I think many arithmetics could be done via this interface and then one could be able to use fix point math in a central place. But besides this, I think that ir would be very good to have a default implementation for the CLR and - from what you are saying - there is or should be one.

Sorry, I could not follow yur explanation about the type parameters. It sounds like you want for example a DirectX matrix to be wrapped into an class extending the matrix interfaces of NTS. At least this would make sense I think :) I would be happy if you could explain this more clearly. Can we use a default implemenation of NTS? I think it should not require DirectX by default (but it should be able to use its benefits).

I would be happy about a new thread targeting a model-view-presenter for CF. A base for this is that sharp map is working for CF, isn't it? I will try my best to pu things together until week end - so that we can discuss about what has been done, what has to be done in other ways and so on.



Jun 4, 2008 at 11:26 PM

I am a bit confused about the status of the CF port, so I'll try to summarize it as far as I understand it, and hopefully someone can clarify:

* The standard version of Sharpmap v2 is at, and contains no CF-specific code.
* There is a partial port by GuillermoTell at, the trunk of which contains early v2 code
* There is another partial port by milovanderlinden at
* There are ports of NPack and GeoAPI by mind_the_gap at
* VansFannel is also working on a port, but haven't commited anything yet(?)

Some questions:
*Does anynone have a version that compiles against CF 3.5 or 2.0, or perhaps even displays maps?
*Despite the name, it looks like the code at is actually *older* than that on At least parts of it are (I looked at FeatureDataSet). Am I missing something?
*I don't understand the directory structure at - the branches/2.0/SharpMap folder contains CFBuild-conditionals, while the branches/2.0/SharpMapCF folder just contains an empty directory tree. Has anyone figured out what has been done in this port?

I might be able to help, but in order for me to be able to convince the people in charge at my company, I'll probably have to be able to display some initial results within a few weeks. If that is not possible, then maybe I can put in some work on my spare time, but that will be a much slower process :-)

Best regards,

Jun 5, 2008 at 7:38 AM

As far as I know there is a working version in It's a port of SharpMap version 0.9. I'm not working on a new port. I need map rotation and find the shortest path, so I'm going to add new functionality. I think that I must use the latest CF version of SharpMap to add this functionality.

There are a lot of CF versions of SharpMap and I don't know what version choose. Maybe I can take SharpMap 2.0, port this source code to CF for me and add this functionality and commit this changes in another server.

I'm wating to mind_the_gap to commit his SharpMap CF version.

@Codekaizen, please, put order in this mess.

See you!
Jun 5, 2008 at 8:19 AM

VansFannel wrote:
@Codekaizen, please, put order in this mess.
I think that Codekaizen has made a lot of work with standard SharpMap v2: I hope that CF port found another main contributor...
Jun 5, 2008 at 8:30 AM

> * The standard version of Sharpmap v2 is at, and contains no CF-specific code

> * There is a partial port by GuillermoTell at, the trunk of which contains early v2 code
True. But this version is pretty old, like you also have mentioned.

> * There is another partial port by milovanderlinden at
Almost True. Milo and I talked some month ago to each other about a new port - unfortunately we only created the SVN space but did not start (due to beeing low on sparse time currently) - Milo created this space and started creating a directory structure - but it is no code in there.

> * There are ports of NPack and GeoAPI by mind_the_gap at
True. We both, Milo and I, created as it seems a SVN space - only on different hosters. Like said above I like assembla more than google :)
In the past month I followed the develeopement of SharpMap v2 and ported now and then versions to the CF (at least I tried to). So did I with the last versions - I developed against CF3.5 and made most of the functionality compile. Unfortunately I did not test the compiled libraries - so I can not say whether it will work or not (but if it compiles, why shouldn't it :) ).
So currently I rework everything to make it a bit more readable and to document the made changes as a base for discussing and talking about what to do and what not (and what could make the port better/easier on the SharpMap-Desktop side).

> * Does anynone have a version that compiles against CF 3.5 or 2.0, or perhaps even displays maps?
My version does compile against 3.5 - but, like said above, I don't know if it draws maps (I did not test it) and I built also no demo application to try this.

> * Despite the name, it looks like the code at is actually *older* than that [...]
You are right, this is a pretty old port.

> * I don't understand the directory structure at [...]
I did not hava look on it but I remember Milo started with a new directory structure and a port of himself (I think). But I could be wrong with this :)

I hope and think to have at least the ported code working by the end of this week (and hopefully the documentation of the made changes, too - luckely there and not that much of them like in the 0.9-Port - due to the higher abstraction libraries like GeoAPI and NTS, ...).
Jun 5, 2008 at 8:53 AM

Who wants to be the contributor?  I can be the contributor but, what have we do with all of CF versions?

Maybe we can find a way to put all of this code in one repository or delete all of this versions and take the latest version of ShapMap and begin porting to CF.

If we do this, we have to adviced people where is the CF version. I'm afraid that there are many people working on the same.

(Sorry for my english)

Jun 5, 2008 at 10:01 AM
It sounds to me like mind_the_gap's port is the one to watch.. At least in terms of closeness to the main v2 effort. If you want me to see if i can run the binaries on WM6 drop me a line.

@mind_the_gap: Out of interest are you using the ManagedBufferedCoordinate2D or have you made a new coordinate using integer/long ordinates? jd
Jun 6, 2008 at 7:26 PM
Edited Jun 7, 2008 at 12:06 AM
@JohnDiss: Yes, I am still on it but will not find time until sunday :( WM6 would be interesting - I try always only WM5 :)

And yes I use ManagedBufferCoordinate2D - But I think it would be of high benefit to implement a integer/long based (or even fix point) coordinate system.

Just for your interest, I commited the net topology port with the SortedDictionary of the Mono project.

Jun 8, 2008 at 3:58 PM

As you know, I'm working on rotation of a map in Compact Framework.

If I use DirectX to rotation I'll probably change ALL of the references of System.Drawing.Graphics with Microsoft.WindowsMobile.DirectX.Direct3D.Device.

Any suggestion? Any advice?

Jun 8, 2008 at 6:49 PM
hm, I think map rotation is a renderer-specific thing - so it should be done in a directX renderer, a GDI-Renderer would deal in another way with this I think. I can currently not say if there is already an interface for rotation, if not we should work one out :)
Jun 10, 2008 at 10:24 AM
Hi there,

I committed a compiling version of the latest SharpMap 2 source. I am pretty sure that not all changes I made (some changes are the ones of the port of last september) do what they are supposed to. This implies that I did not try the nunit tests for now - I hope I will come to this in the next view days.

Moreover the compiler complains that 1. "SharpMap.SimpleGeometries.Extents" and 2. "SharpMap.SimpleGeometries.GeometryFactory" do not implement the interfaces correctly (1. with missing Transform and 2. with missing CreateGeometryCollection" - did I use a wrong version GeoAPI (I took the last available)?

Another thing is that I still found no time to document everything to make a discussion out of the changes made and what possible solutions could be found to some problems I (and you, too, I think) see.


Jun 10, 2008 at 11:32 AM
Hi Tom, don't use simple geometries - use the ones in NTS instead.. HTH jd
Jun 10, 2008 at 11:58 AM
Edited Jun 10, 2008 at 6:12 PM

ok, thanks, so SimpleGeometries is removed again from SVN.

I also committed the Gdi Renderer - it uses the NTS matrices.

Can someone please explain me how the "rendering pipeline" works in v2? Do the Figures (text, polylines, ...) get passed to the specific render (i. e. the gdi renderer) which then generates a RenderingObject - and then? What to do with it? How is an image obtainend - by the presenter?



Jun 10, 2008 at 10:23 PM
Hi Tom, my understanding so far is:
MapPresenter2D listens to the view.
On changes to the extents/ bounds etc, it requests the geometries from the provider.
On reciept it sends the geometries to a map renderer (currently inplemented as BasicGeometryRenderer<TRenderObject> but open to other implementations - the constructor of this takes in a VectorRenderer in your case a GdiVectorRenderer). 
BasicGeometryRenderer then converts the geometries into sharpmap abstracted paths and figures.
These paths and figures are then sent to the approriate VectorRenderer (the GdiVectorRenderer) where they are turned into an IEnumerable<TRenderObject> (in this case a GdiRenderObject containing a GDI specific path, pen brush etc)
These are then returned to the presenter which then calls ShowRendererdObjects on the view.
In the case of the desktop control they are queued and then dequeued in the OnPaint call where the gdi paths are finally rendered onto the canvas

I may have missed a bit...
HTH jd
Jun 11, 2008 at 10:05 PM
Thank you very much John, this gave me a rough idea what is going on :)
I started to port the WinForms-Presenter as a starting point for testing. Unfortunately I ran pretty fast into some more problems (of which kind, I think, are more to come) - for example:
1. "System.Data.DataView+RowPredicateFilter" seems not to exist in the Compact Framework - I commented this and the stuff which needs it out, but it seems that this causes that a layer has instead of Features an empty FeatureDataTable ... Maybe we could use Linq in here?
2. Type.TypeHandle does not exist in Compact Framework - I don't know if it is save to use only the Type and no handle (?)

Well, at least the ShapeFile seems to get parsed but I could not test more since layer.Features is an empty FeatureDataTable. I guess it should be filled automatically?

Jun 12, 2008 at 2:02 AM
This is probably the longest thread on CodePlex.

Sorry it's taken so long to reply - I've been under the gun for some deliverables.

John has got it right for the MapPresenter2D: the actual view computation is done there. It is not done in the graphics library. Currently, an intermediate representation of the matrixes used to construct the view transform use internal matrix types, and so rotation would be stored in MapPresenter2D's rotation transform matrix. Longer term, the idea is to eventually parameterize the matrix type so that a more native one can be used: every graphics technology we can use has a matrix type. We can just provide the interfaces and perhaps type parameters so we can use them. Eventually, this should allow extremely high-performance rendering which can take place entirely on the GPU, since all vector and matrix data would be stored and manipulated there. This also allows us to create a fixed-point type to represent coordinate data, as had been mentioned. In this light, ManagedBufferedCoordinate2D is a stop-gap measure to provide a working model and proof-of-concept. My hope is that this functionality would be moved out into a graphics-specific coordinate and matrix package, perhaps even in the same assembly as the graphics-specific renderer. With snap-rounding where appropriate to solve robustness issues, this could be made to work for any kind of display and geometrical algorithm. As you can see, this is pretty ambitious, so anyone who has any interest here would be warmly invited to think about how to factor the types to allow this abstraction. I'm currently stuck on how to provide a type-parameterized matrix implementation which could flow down to the few classes (renderers, cartographic projection, certain geometry operations) which need it without peppering "TMatrix" all over the place.

@mind_the_gap: I'm quite interested in a fixed-point coordinate representation, since most compact devices use fixed-point acceleration, and this would provide more power to drive SharpMap.
Jun 12, 2008 at 2:08 AM
Oh, and @mind_the_gap, about those two issues:

1. "System.Data.DataView+RowPredicateFilter" seems not to exist in the Compact Framework - I commented this and the stuff which needs it out, but it seems that this causes that a layer has instead of Features an empty FeatureDataTable ... Maybe we could use Linq in here?

I think the thing to do would be to throw out DataView as the class which clients bind to and replace it with IBindingList<IFeatureDataRecord> or some descendent. The RowPredicateFilter is actually how ADO.Net integrates with LINQ, and didn't show up until 2.0 SP1. I remember shouting for joy when I found it, since it was the only way to filter a DataView using spatial predicates, and then sobbing in horror once I realized it wasn't in .Net 2.0 RTM. Exposing selection and highlighting via DataView as a concrete class was a mistake. The right thing to do is to expose it via an interface: IBindingList<IFeatureDataRecord> would be a natural one.

2. Type.TypeHandle does not exist in Compact Framework - I don't know if it is save to use only the Type and no handle (?)

I can't believe this! Those crazy CF folks. Well, there has to be a way to get the RuntimeTypeHandle from a Type in CF. They are much more efficient to store and reference types by.
Jun 13, 2008 at 3:33 PM
Oh thanks for the rendering explainationts. So if the actual view computation is done in the presenter - the renderers and preserters should exist in pairs, shouldn't they? Like a DirectX-Renderer and a DirectX-Presenter.
On CF Gdi there is no native matrix type - so all the per-vertex matrix computations have to be done manually - this should happen in the presenter, too?

The abstraction of the graphics stuff sounds good and I will spend some thoughts on this - but I would like to have a basic version of SharpMap CF working - which seems to be time consuming enough at the moment. After this the fixed-point coordinate representation is on the plan :)

To the suggestions on the mentioned problems:
1. How should the IBindingList<IFeatureDataRecord> be integrated? I am still not that familiar with the whole structure and design of SharpMap v2. Another thing of creating FeatureDataViews is that the setIndex2 method does not exist and the MethodHandle no GetFunctionPointer method offers.

2. I asked on the CF mailing list but got also the answer that it is not possible - though it is strange that there is the RuntimeTypeHandle Type and the TypeHandle field (which retunrs in test and like listed on MSDN a NotSupportedException).

There is much to do :)
Jun 13, 2008 at 4:59 PM


Let's number these issues differently:

  1. Rendering/Presentation: Yes, the presenter/view and renderer will likely exist in pairs, although for the presenter much of the functionality can be assumed by a base class. In the case of web rendering, John's work in v1.1 experimental indicates that it is possible that all functionality can be assumed by a base presenter. If there is no matrix, it can be provided by a different implementation, eventually in the coordinate model which is used by a given renderer.
  2. Feature data: The IBindingList<IFeatureDataRecord> (or perhaps IBindingList<TFeatureRecord>) would be implemented on the current FeatureDataView. Then all the client objects of FeatureDataView would be repointed to the interface, reducing coupling and allowing an implementation which is not FeatureDataView, and avoids the problems of it not being supported in it's current state on CF. Of course, a completely new implementation for CF may be needed, and this would be work, but it would be the correct factoring.
  3. Type Handles: This is just insane. Apparently there is a method to get a type given a type handle (System.Type.GetTypeFromHandle()) in CF, but no way to get the type handle. I'll look into this a bit, since I'm not ready to give up type handles. Too bad there is no SSCLICF to tear into.
Jun 21, 2008 at 8:52 PM
Edited Jun 21, 2008 at 10:24 PM
I'm absolutely lost.

I'm using Sharpmap v.0.9 for C.F. I found methods in VectorRenderer class like DrawLabel comented because there isn't matrix rotation in CF. Somewhere, in another thread, someone said that if we use DirectX in rendering we can improve performanced on devices running Windows Modile.

Maybe I haven't got the enought knowledge of SharpMap to face this (I don't understand anything that it said on this thread).

I'll tell you if I can do something on rotation, but maybe there is another person working on the same thing at this moment.

And another thing that make me feel lost is Type.TypeHandle. As you can see in this web Type.TypeHandle exists in Compact Framework. You can try the example on a Smart devices project and see that works perfectly.

See you!
Jun 22, 2008 at 12:55 AM

Hi VansFannel -

Sorry to hear you're lost. There has been a lot of topics on this thread and my subtle efforts to take specific questions onto new threads has not been fruitful. I think that is a major source of confusion.

As far as rotation is concerned: it is the responsibility of the MapPresenter to do this. It holds the matrixes which are used to transform world coordinates to view coordinates. There is a specific rotation matrix in the MapPresenter2D to rotate the entire view.

As to DirectX, yes, it would probably speed up render operations on mobile platforms, especially as mobile graphics get better at the end of the decade (2009-2010).

As for Type.TypeHandle, yes, it does exist, but it is not implemented. It throws a NotImplementedException. The MSDN doc says this, as does Reflector:

Exception Condition

The .NET Compact Framework does not currently support this property.

Jun 22, 2008 at 1:16 PM
Hi codekaizen -

You're right about Type.TypeHandle. Sorry. It's so strange that we have this property and we can't use it!

I'm lost because I don't know where can I find information about all SharpMap's functionalities maybe because I don't know so much about GIS. Yesterday I found a method called DrawLabel and surprise!! It can draw labels! I'm only using SharpMap to show a shapefile.

Well, I'll work on rotation in Compact Framework. Maybe I'm going to change all references of System.Drawing.Graphics to DirectX.

codekaizen- Thanks for all of your support!

Jun 22, 2008 at 4:41 PM
And... a question for @mind_the_gad:

Where did you commit the SharpMap 2.0 CF version?


P.D. There is a lot of information on this thread!
Jun 23, 2008 at 5:26 PM

Hi there,

sorry, currently I have absolutely no time :( - hopefully this will change the following week (at least I finish a project in this week).

@VansFannel: Here it is:
It is not the most up-to-date version - Its about 6 commits old :P (in relation to the current version of SharpMap 2)

Jun 23, 2008 at 5:33 PM
@mind_the_gap -

I've taken some time to try and crack the TypeHandle problem. I'm currently working on a bit of unmanaged code to help out, and hopefully I can get around this issue by the time you come around again...
Jun 23, 2008 at 6:00 PM
Edited Jun 23, 2008 at 8:19 PM
@codekaizen: great :) I am thrilled to see your workaround :)
Jun 25, 2008 at 8:38 AM
Rotation on Compact Framework.

I was asking about using DirectX on Pocket PC, and from Microsoft answer me this:

Due to poor driver support from device manufacturers he suggested me to use another thing instead.

I'll continue using System.Drawing.Graphics and rotate coordinates before asign to the methods.

Stay tuned!
Jun 25, 2008 at 9:03 AM
Hi VansFannel - this looks interesting - but slow.. and if you like voiding warranties the rest of xda-developers has some good tips too
Jun 25, 2008 at 9:44 AM
Hi JohnDiss.

I prefer DirectX but there is some driver problems so I'm trying to make it as portable as I can (avoiding voiding warranties).
I don't know how much slow it can be.
Jun 25, 2008 at 1:18 PM
Edited Jun 25, 2008 at 1:52 PM
Actually, the reference driver is redistributable, but it is so slow that it is impossible to even debug.

In general, the state of affairs with mobile graphics drivers is a sad one, no doubt, but these things are rushed to market. Every device I've seen has a firmware update 6 mo. to 1 yr. after release which basically brings the device to a usable state, 3D graphics drivers included. My Treo 700W, for example, runs Mobile DX surprisingly well... but it's over a year old.

I wouldn't be discouraged - keep up with the DX path. Over the next year the situation should improve what with NVidia pushing into the market (wait, will this really help?) with the Tegra. Mobile DX (in the form of XNA) runs on the XBox and from what I gather, the Zune soon (v3.0 CTP). At any rate, even now, the mobile device target is spotty at the worst. Unless you need to target a very specific device which has a broken driver and no hope of recourse to get it fixed, this worst-case scenario isn't too bad.

If you do become discouraged, however, a GDI matrix can be rotated, too (it's a matrix).

However, you really shouldn't be doing rotations with a GDI or DX matrix, unless you want to completely replace the functionality of MapPresenter2D (not recommended). Have you just tried setting up the rotation matrix in MapPresenter2D to rotate how you want (I'd guess by 90 degrees)? I know this contradicts my encouragement to have you keep looking at Mobile DX: I'm excited to have someone looking at it, yet I'm concerned about not having the wheel be reinvented.
Jun 25, 2008 at 2:40 PM
Edited Jun 25, 2008 at 2:42 PM

I'm working with SharpMap v.0.9 for Compact Framework. I just downloaded version 2.0 and I see there is a lot of changes from version 0.9.

In version 0.9 the rotation functionallity it's comented because Graphics.TranslateTransform and Graphics.RotateTransform don't exist in Compact Framework.

I'm going to use SharpMap v.2.0 (committed by mind_the_gap) when I sure its works, meanwhile I'm studying all the posibilities and tell them to you (I don't have so much knowledge about graphics and SharpMap so I NEED YOUR HELP!!!).

Or I'm losing my time and yours because rotation it's implemented in SharpMap 2.0 for Compact Framework and works perfectly (sorry in that case).

Jun 25, 2008 at 4:22 PM
Ah, I see now... there is no Matrix in GDI for Windows CE.

Well, SharpMap v2 brings it's own matrix for rotations, and does the linear transform of the world to view outside of the graphics... in fact, running on different graphics platforms was one of the major motivations for separating the rendering from the computation with v2.

As for your situation with v0.9, you can perhaps make use of the only rotation available via CF: I'm not sure if there is already a managed code way to do this (I might suspect so), but a quick p/invoke would take care of it nicely if not.
Jun 27, 2008 at 1:00 PM
I found this to make rotation:

I'll try it this weekend.
Jul 4, 2008 at 12:48 PM
No way.

Maybe I'm trying to implement something that it's implemented in SharpMap 2.0 Compact Framework version.

This is what I want to do:

Now, the top of the map represent the north. Because the map doesn't rotate, the north it's always in the top of the map. If the user it's looking to the south the image of the map must have the south in the top.

I'm going to use the bearing given by the GPS to rotate the map. Look up this web to learn about GPS sentence GPRMC: (look for Bearing).

Can I rotate the map giving it this angle (bearing) in SharpMap 2.0?

Thank you!
Sep 6, 2008 at 1:49 PM
Edited Sep 7, 2008 at 1:03 PM

I just downloaded SharpMapCF from

When I try to compile NetTopologySuiteCF it allways crash Visual Studio 2008 Team System. I donwloaded also SP1 for VS2008 and its continues crashing me Visual Studio.

Where is the error? Anyone can compile it?

Come on! Only one to one hundred post!


Update 2008-09-07 - 08:54 UTC

It also crashes if I compile from comand line using c:\devenv NetTopologySuiteCF.csproj.

This is the log:

Microsoft (R) Visual Studio 9.0.30729.1.
(C) Microsoft Corp. Reservados todos los derechos.
------ Operaci¢n Generar iniciada: proyecto: NPackCF, configuraci¢n: Debug Any CPU ------
NPackCF -> C:\Fuentes\Bibliotecas\WindowsMobile5.0\SharpMapCF2.0\NPack\NPackCF\bin\Debug\NPack.dll
------ Operaci¢n Generar iniciada: proyecto: GeoAPICF, configuraci¢n: Debug Any CPU ------
GeoAPICF -> C:\Fuentes\Bibliotecas\WindowsMobile5.0\SharpMapCF2.0\GeoAPI\bin\Debug\GeoAPI.dll
------ Operaci¢n Generar iniciada: proyecto: SharpMapCF, configuraci¢n: Debug Any CPU ------
SharpMapCF -> C:\Fuentes\Bibliotecas\WindowsMobile5.0\SharpMapCF2.0\SharpMapCF\bin\Debug\SharpMap.dll
------ Operaci¢n Generar iniciada: proyecto: AccesoDatosTurismoMobile, configuraci¢n: Debug Any CPU ------
AccesoDatosTurismoMobile -> C:\Fuentes\Bibliotecas\WindowsMobile5.0\AccesoDatosTurismoMobile\bin\Debug\AccesoDatosTurismoMobile.dll
------ Operaci¢n Generar iniciada: proyecto: SharpMap.Rendering.Gdi, configuraci¢n: Debug Any CPU ------
SharpMap.Rendering.Gdi -> C:\Fuentes\Bibliotecas\WindowsMobile5.0\SharpMapCF2.0\SharpMap.Rendering\Gdi\bin\Debug\SharpMap.Rendering.Gdi.dll
------ Operaci¢n Generar iniciada: proyecto: OpenNETCF.IO.Serial, configuraci¢n: Debug Any CPU ------
OpenNETCF.IO.Serial -> C:\Fuentes\Bibliotecas\WindowsMobile5.0\OpenNETCF.IO.Serial\bin\Debug\OpenNETCF.IO.Serial.dll
------ Operaci¢n Generar iniciada: proyecto: NetTopologySuiteCF, configuraci¢n: Debug Any CPU ------
NetTopologySuiteCF -> C:\Fuentes\Bibliotecas\WindowsMobile5.0\SharpMapCF2.0\NetTopologySuiteCF\bin\Debug\NetTopologySuite.dll

And the crashes.

Update 2008-09-07 13:00 UTC

Building the solution with MSBUILD I got a system.StackOverflowException.

Any advice?
Sep 8, 2008 at 7:44 AM

If I disable PlatformVerification building the solution with MSBuild I can build all the solution without error. But I can't analyze the NetTopologySuiteCF.dll with FXCop because it gets two errors. Maybe the dll generated it not totally compatible with Compact Framework.

SharpMapCS_VS2008.sln references to .\NTS\NetTopologySuiteCF\NetTopologySuiteCF.csproj but I checkout .\NetTopologySuiteCF\NetTopologySuiteCF.csproj.

Is correct the source code that I checkout from

Sep 12, 2008 at 6:54 PM

Hi there,

sorry for the delay - currently I have absolutely no time to contribute to this :(
I hope to get in the end of september to this and update the sources to the current version and maybe even to a complete port.

The URL you use is correct, yes. Unfortunately, I can not tell what the problem is - I can compile everything without problems. I will try to investigate a bit by trying to compile on other machines. Like stated above will I not be able to do much currently as my time tables seem to burst...

Sep 12, 2008 at 8:08 PM

I compile the library in two diferent machines and I obtain the same error. The machines are:

Windows XP SP3 (Spanish)
Visual Studio Team System 2008 SP1 (Spanish).
Target platform: Windows Mobile 5.0 Pocket PC SDK.


Sep 21, 2008 at 2:27 PM
VS2008+sp1, windows XP SP3, target don't change.
SharpMapCF Revision 11, not build with 14 error:
Error 1 Expected class, delegate, enum, interface, or struct R:\map_gps\SharpMapCF\SharpMapCF\Presentation\Presenters\LayersPresenter.cs 218 11 SharpMapCF
Error 2 Expected class, delegate, enum, interface, or struct R:\map_gps\SharpMapCF\SharpMapCF\Presentation\Presenters\LayersPresenter.cs 239 11 SharpMapCF
Error 3 Expected class, delegate, enum, interface, or struct R:\map_gps\SharpMapCF\SharpMapCF\Presentation\Presenters\LayersPresenter.cs 244 11 SharpMapCF
Error 4 Expected class, delegate, enum, interface, or struct R:\map_gps\SharpMapCF\SharpMapCF\Presentation\Presenters\LayersPresenter.cs 252 66 SharpMapCF
Error 5 A namespace does not directly contain members such as fields or methods R:\map_gps\SharpMapCF\SharpMapCF\Presentation\Presenters\LayersPresenter.cs 273 6 SharpMapCF
Error 6 Type or namespace definition, or end-of-file expected R:\map_gps\SharpMapCF\SharpMapCF\Presentation\Presenters\LayersPresenter.cs 276 4 SharpMapCF
...Error 16 Metadata file 'R:\map_gps\SharpMapCF\SharpMapCF\bin\Debug\SharpMap.dll' could not be found SharpMap.Demo

I would eagerly wait for new versions. Thank you for your work!
Sep 22, 2008 at 5:06 AM

You probably don't define precompilation symbol NETCF.

See you!
Sep 22, 2008 at 6:18 PM
GS yes! In point.
SharpMap.Demo - ILayerFactory.cs - line 215 col 13 - delete }
And ......
.... 49 error  :-) Don't open projects ManagedBufferedCoordinate2DCF and NetTopologySuiteCF becose path name bad path
SharpMapCF/NTS/NetTopologySuiteCF - wrong NTS

edit path in solution .... reload solution .... and 62 errors. It is a pity. Tomorrow will continue the search.
Sep 22, 2008 at 7:48 PM
Edited Sep 23, 2008 at 7:24 AM

I have a ILayerFactory with 27 lines only on project SharpMapDemo. Try to checkout source code again.

There is another precompiler symbol DOTNET35.

See you

Update: In some projects there are files that they are not use. Don't forget to use the original VS2008 project file.
Sep 25, 2008 at 10:46 PM


maybe you have thought that everything will compile fine already - but that is not the case. There are still some errors to be taken down. Until the 04. of october I will not have any chance to look into this project again. But the upside is that it seems that I can do the port as part of a university project (I study information technology) and I can bring in a lot more time - hopefully starting with mid october.

@codekaizen: How far have you come in solving the TypeHandle issue? Have you found anything that helps - if you have not time to do it, can you supply some hints?

Best Regards,

Sep 29, 2008 at 2:21 PM

maybe I missed something but allow me to ask you, more experienced people, few questions.
(as you can see, I'm new guy :-) )
My company is about to start a little project for pocket pc.
I'm searching for compact framework SDK which would meet these minimum requirements:

1) read and display shp files
2) edit shp files (it is not needed to edit polygons, enough is to be able to create, edit and delete points)
3) display raster files (for example georeferenced JPG)
4) standard vector/raster layer manipulation ((window) zoom-in, (window)zoom-out, drag)
5) identify selected object (click -> return shape index, or some other feature - i saw ExecuteIntersectionQuery proc.)
6) maybe support for basic GPS reading - positioning.

I googled a little bit and found SharpMap. I'm a little bit confused with status of SharpMapCF v2 project. I downloaded it from and I could not compile it (it crashes my VS2008). I tried to do something with 0.9 port from  I managed to open shp file, and identify pointed object but I see that there is no support for shp file editing (am I wrong?) Is there any working version of SharpMap which would meet those 5-6 requirements? If there isn't, can you recommend commertial SDK (I found the one from TatukGIS but their starting price is simply too high for functionality that I need and the expected number of deployments). Thanks in advance!

Sep 29, 2008 at 2:47 PM
Edited Sep 29, 2008 at 2:52 PM

I have the same error with SharpMapCF v2 (it crashes my VS2008). It something about PlatformVerification as you can read above. I'm sorry, but I don't know how to solve this error.

With SharpMap 0.9 there is no edit shapefile support.

Sep 29, 2008 at 3:19 PM
It's a pitty. I would like to offer man or two to contribute, but we don't know anything about SharpMap. Since experts haven't solved it yet, we have got no chance.$0BTW: is there any documentation regarding SharpMapCF object model, principles, problems, etc.$0$0$0$0$0@VansFannel: Any recommendation for commertial component (GIS CF SDK)? (I'm sure you have searched - I see it has been tough for you as well :-) )$0$0$0$0$0Best regards.$0
Sep 29, 2008 at 4:07 PM

I have no idea about commercial products.
Sep 30, 2008 at 12:01 PM

You could take a look at GpsTools ( and GeoFrameworks (, both of which are commercial SDK:s for writing gps/mapping applications.  I haven't  looked much at them, but they both work with .Net CF and I think they're able to do what you want.
Oct 3, 2008 at 7:17 AM

Could you try to update the repository? Maybe you have a newer version of the source code.

I can't find where is the problem on NTS. The other projects build fine.

Thank you!
Oct 24, 2008 at 8:31 AM

I'm still working on the NTS problem. I don't know how to solve it

See you!
Oct 24, 2008 at 2:56 PM
i'm new on SharpMap,
i'm develop GIS application and i'm so interested by this port.
if i can help...

Actually i've taked the actual released, and it compile.
But i've got a problem in the SharpMap.Data.FeatureMerger in GetMergerInvoker.

The AdoNetInternalTypes.MergerType is not defined because the type System.Data.Merger not exist in System.Data.

Can you help me?

Oct 24, 2008 at 4:20 PM

Oh!, another one that can compile successfully SharpMap 2.0 Compact Framework version.

I can¡t help you if I can't compile.

See you!
Oct 24, 2008 at 4:25 PM
I can't compile NetTopoligySuite,
but i use the NetTopoligySuite.dll in release directory to compile the solution without NetTopoligySuite project.
Nov 14, 2008 at 3:15 PM
Edited Nov 14, 2008 at 3:16 PM

Any progress?

How can I help you?
Nov 21, 2008 at 1:30 PM
No progress for the moment,
I don't find where is the problem in nettopology for the moment.
Nov 26, 2008 at 2:28 PM
Hi Yero,

If I disable PlatformVerification building the solution with MSBuild I can build all the solution without error. But I can't analyze the NetTopologySuiteCF.dll with FXCop because it gets two errors. Maybe the dll generated it not totally compatible with Compact Framework.

Maybe it's something about the porting. I don't know how @mind_the_gap can build the dll and none else can do it.

I found a previous old version of NTS that works perfectly for Pocket PC here:

I'm going to use this version because I don't know where is the error neither!!!!

See you!!