Thursday, 6 May 2010

Xsd2Code

If you have used xsd.exe before to generate C# code from XSD schema files you may have bore witness to some of the most horrendous looking serialization code that's ever been generated:
  • A repeating element becomes an array property with full get and set. (How are you supposed to add elements?)
  • Child object properties of generated classes must explicitly be created and assigned when creating a new instance of said class. (A recipe for NullReferenceException hell)
Just to name a few.

I was scouring the web hoping that there would be a better way to do this. I was on the verge of giving up until I encountered this link from stackoverflow:


In the short time I've played with this tool, I am already impressed at the quality of code that it generates. Just to illustrate how good this is:

Here's the Parameter property for the MaestroAPI FeatureSource class as it currently stands (generated by xsd.exe):

[System.Xml.Serialization.XmlElementAttribute("Parameter")]
public NameValuePairTypeCollection Parameter {
get {
return this.m_parameter;
}
set {
this.m_parameter = value;
}
}

If we created a new instance of FeatureSource and tried to access this property a NullReferenceException is thrown because you have to manually new the NameValuePairTypeCollection and assign it to this property yourself!

Here's the same snippet as generated by Xsd2Code

[System.Xml.Serialization.XmlElementAttribute("Parameter")]
public List<NameValuePairType> Parameter
{
get
{
if ((this.parameterField == null))
{
this.parameterField = new List<NameValuePairType>();
}
return this.parameterField;
}
set
{
if ((this.parameterField != null))
{
if ((parameterField.Equals(value) != true))
{
this.parameterField = value;
this.OnPropertyChanged("Parameter");
}
}
else
{
this.parameterField = value;
this.OnPropertyChanged("Parameter");
}
}
}
Creating a new instance of this FeatureSource, we can safely access this property because it has lazy generation logic built in! Xsd2Code does other things as well, such as providing built-in serialization/deserialization logic, object cloning, and much more!

I'm a bit disappointed that the property still has a setter (collection properties should almost never be assignable!), but already this code is much cleaner and easier to work with than the one generated by xsd.exe

Just seeing some of the code that's generated with some of the mapguide xsds, I knew that I have found my saviour. So long xsd.exe!

I will definitely be using this tool for the next (post-2.1) version of the Maestro API and any other projects that involve working with xsd files.

Tuesday, 4 May 2010

WebTier-less editing with Maestro

Just landed in trunk, is experimental support for using Maestro using the offical MapGuide API (known as LocalNativeConnection in Maestro). What this means is that when Maestro starts up you are now greeted with a slightly different login dialog.


Notice the two radio buttons Connect via HTTP and Connect via TCP/IP, when the Connect via TCP/IP button is clicked, you get a different user interface


If you ever used the offical MapGuide API, you should know how this works. Give your login details, supply the path to the webconfig.ini and away we go.


Where is the value in having offical MapGuide API support? It means it is now possible to edit resources in a MapGuide server without the need for a web server and web extensions installed on your machine!

For people (like me) who test bleeding edge versions of MapGuide built from source this is a very useful feature to have. This doesn't work perfectly yet. It bombed out on me when opening feature sources (some xml serialization bug), but it's a promising start.

Tuesday, 20 April 2010

The apt-get dream is getting closer

As some of you already know, a new MapGuide LiveDVD is in the works, to be made available at FOSS4G 2010

Unlike the previous attempt, what excites me about this LiveDVD release is the surrounding work on having functional out-of-the-box binaries for Ubuntu Linux!

Building mapguide from source in linux has been a major source of pain and frustration and it is nice to have pre-built binaries to avoid all that mess.

There's still some hurdles to overcome, but sudo apt-get install mapguideopensource is that much closer to reality.

On a sidenote: full credit to Trevor Wekel from OTX Systems for spearheading this initiative. Please consider donating to support some of his other initiatives, among which is to have a stable GDAL raster provider, which is something we could all do with.

Wednesday, 14 April 2010

More installer flexibility in MapGuide Open Source 2.2

The (soon to be beta) release of MapGuide Open Source 2.2 will include an even more flexible installation experience.

In addition to configurable IIS web sites, you also get:

Configurable port numbers


Configurable virtual directory name and web server port (for Apache)


Configurable virtual directory name for IIS


All these changes ultimately make it easier to install 2.2 alongside an existing 2.1 or earlier release, by making the common points of conflict all configurable.

Side-by-side installation is not a supported scenario, but at least these changes will make it easier for you should you choose to take that path.

Look familiar?






Now where have I seen this before? :D

Tuesday, 13 April 2010

New Maestro Feature: Load Procedures!

If a picture is worth a thousand words. Then this post is worth 5000 :D






You may notice that some of the UI elements in the Transformation section are disabled. That's because these features are not supported in Maestro, and are ignored when the load procedure is executed.

The motivation for Load Procedure support was simply to satisfy the use case of "quick and dirty" loading of SDF/SHP files into MapGuide with default (monochromatic) layer styles.

I will be posting a 2.1 preview build soon that will have this and much more

Thursday, 8 April 2010

FDO Toolbox is dead. Long live FDO Toolbox

This post is an official announcement that development of FDO Toolbox will be winding down.

The reasons for winding down are three-fold:

1. My original goals of FDO Toolbox have been met. With the exception of certain esoteric bits of the FDO API, my primary design goal of FDO Toolbox being a "front-end" to the FDO API has been effectively met.

2. I am taking over from Kenneth Skovhede as the primary maintainer of MapGuide Maestro.

3. Now being the primary maintainer, Maestro is now my primary focus. My long-term vision for Maestro is to have the data creation, querying, analysis and ETL capabilities of FDO Toolbox in addition to the publishing capabilities of Maestro, forming the ultimate tool for geospatial data. So to this end, you will see many parts of FDO Toolbox being merged into future releases of Maestro. So in a way FDO Toolbox will live on as part of the Maestro project.

Version 1.0 of FDO Toolbox, which will have the final version of FDO 3.5.0 will be the final release. After that, I'll be moving on full-time (my free time that is :D) to the MapGuide and Maestro projects and as a result, you'll be seeing more Maestro-related bloggery in the future.

R.I.P. FDO Toolbox (2008-2010)