Using GDAL from C#

Recently Frank Warmerdam and Michael Paul posted some examples on calling GDAL from .NET. This is pretty cool, since this enables you to access a great set of tools that I for one have been accessing by generating batch-files in a .NET application and then running them using the shell-commands (not pretty but it worked :-)

Their posts used several links to pointers and didn't have automatical garbage collection. Since disposing objects is very important when calling unmanaged code, and .NET developers isn't that used to pointers, I decided to wrap some of the GDAL functionaly into a few classes with automatic disposer etc. It still needs some brushing off and to include some more GDAL functionality, but let me know what you think. You can download it here.

MapServer Enterprise

Yesterday The MapServer Foundation announced the availability of the new (and free!) MapServer Enterprise sponsored by AutoDesk.
They state that it also supports .NET, which sounds like goodies for a .NET/GIS guy like me, so I definitely had to check it out.

I must admit that their ASP.NET examples shocked my completely. I can’t recall seeing that poor .NET code the last couple of years. It’s all ASP-style spaghetti-code and ridiculously poor implemented. I wouldn’t be surprised that if you rename the file-extensions to .asp, it would still run :-) Although I’m still exited by this new release, I can’t help thinking that if this is the best they can do in a .NET environment, what does the actual server-code look like?

SharpMap as a WMS server

Today I was trying to make a WMS implementation using SharpMap, and it turned out to be quite easy. I’ve implemented some helper classes in SharpMap, which I will include in the next release of SharpMap. Actually now you can create a WMS service using only a few lines of code. Here’s an example:

protected void Page_Load(object sender, EventArgs e)
{
    SharpMap.Map myMap = InitializeMap(); //Call method that sets up your map
    SharpMap.Web.Wms.WmsServer.ParseQueryString(Request.QueryString,Response,myMap);
}
And that’s it !!! (well at least besides the InitializeMap method where you set up layers etc…)

It even returns nice little XML exceptions according to the specification. I still need to do some work on the GetCapabilities request, but I think it’s more or less safe to say that SharpMap will work as an OpenGIS compliant WMS Server in the next release.

Shapefile indexing

I've just finished creating on-the-fly spatial indexing for shapefiles in SharpMap, and what an improvement !!! Rendering a shapefile layer to a map is now 5-6 times faster compared to a spatially indexed PostGIS layer. I'm now focusing on getting ready for the SharpMap v0.8 release, which includes the shapefile indexing, a new improved geometry object model, and a bunch of other changes and enhancements.

SharpMap Sourcecode and WMS support

The source code for SharpMap is now available too, as well as some feature changes. Biggest change is support for using WMS layers. I you don’t have access to vector data or a PostGreSQL database, you can still aggregate data from several WMS servers and display them in you very own map application. I’m still working on shape file and raster support.

Rendering maps using .NET

Last night I was, just for fun, fooling around with creating my own mapserver engine using native .NET and GDI+ methods, combined with a PostGreSQL/PostGIS database. Until now I got Points, Labels and Line layertypes implemented.
I didn’t expect much of the speed, but it turned out that GDI+’s drawing methods and anti-aliasing rendering combined with .NETs automatic connection pooling provided me with an ultra fast map render engine. And just by exposing LineStyles as System.Drawing.Pen you get a vast amount of options for customizing the look of the rendered output. And it even looks great! I’m all ecstatic about the result, and will probably follow this further with more geometry types and additional data-providers (shapefile, Oracle etc). I’ll post some results here later.

PocketGpsLib Class Diagram

I was looking into doing some unit testing, when I just (re)discovered a cool new feature in VS2005. You can auto-generate a class-diagram from your projects, just by right-clicking and select "Class diagram". Below is a class diagram for parts of the upcoming release of PocketGpsLib 2.0, as of today. Better get back to setting up some unit tests... :-)

PocketGpsLib v2.0 update

These last couple of days, I’ve been working a lot with the PocketGpsLib in the new Visual Studio 2005 beta 2 IDE. Working with and testing the library, I stumbled across quite a few bugs in the NMEA parser that sometimes occur, even in the old release. Pretty embarrassing considering the current 600+ downloads of the library, although it usually parses the data correctly :-)

I’ve also been redesigning the API quite a lot, and I think it’s moving toward a much slicker API. Are you also working with .NET Compact Framework 2.0 beta2, let me know if you’re interested in testing the library.