Monday, 15 August 2011

Announcing: MapGuide Maestro 3.5 final + SDK

I'm happy to announce the final release of MapGuide Maestro 3.5 and SDK

New Features from 3.5 beta 2:

  • Layer editor now supports multiple composite styles per scale range

  • New informative progress dialog for map definition extent calculation

  • New "Copy Resource IDs to clipboard" context menu command

  • New Symbol Definition Validation rules

  • Client-side support for transforming coordinates to WGS84.PseudoMercator. It should now be possible to change your Map Definition coordinate system to WGS84.PseudoMercator, and have the extents automatically transformed to match, and immediately usable in a Fusion Application Definition with a Google/Yahoo/Bing backdrop


New in the SDK is a new sample: StandaloneWebLayoutEditor. This sample illustrates how to use the Maestro.Editors library to re-use the Maestro resource editors from outside of MapGuide Maestro.

Download
Download SDK

Saturday, 6 August 2011

Announcing: MapGuide Maestro 3.5 beta 2

I'm happy to announce the second beta release of MapGuide Maestro 3.5

One of the interesting new features is in-place upgrading of resources to the latest schema version. You know that pale yellow bar at the top with that upgrade button that's always disabled?



It's now enabled, and when you click it it will upgrade the edited resource to the latest schema version supported by the MapGuide Server you're connected to.



Once upgraded, the editor refreshes itself and the new editor features for that schema version become activated.


This is supported for all resource editors. Currently the conversion is one-way (always to the latest schema version. I may look at converting to a specific version in a future release.

Other new features and changes include

  • Enhanced Autodesk Infrastructure Map Server 2012 support

  • Previewing is now enabled for Watermark Definitions

  • Map Definition support for re-ordering layer groups

  • Layer Definition editor now supports inline symbol definitions for composite symbolization

  • A whole bunch of assorted productivity improvements (too many to detail, but you'll recognise it when you see it)

  • The usual assortment of bugfixes


This is the last beta release before the final 3.5 release

Download

Friday, 5 August 2011

Maestro API: 3 ways to create and work with resources

As explained previously, the Maestro API allows you to work with MapGuide resources in an object-oriented manner, completely avoiding the need to work with raw XML content (although the Maestro API provides such facilities should you require them)

What I didn't fully explain was how one actually can create retrieve and work with these objects. In the Maestro API, there are 3 ways to do this.

First way: Using the ObjectFactory class

The ObjectFactory class allows you to create resource objects from scratch. This method was available in the previous version of the Maestro API, but because you were working with generated classes, there was a very high chance of NullReferenceExceptions and DBXML errors being thrown at your face because you forgot to instantiate one or more of its many child properties.

The ObjectFactory class insulates these concerns away for you. Any resource you create via this approach satisfies the minimum content model requirements of its respective XML schema.

Here's an example of creating a feature source object to a SQL Server 2008 Express database from scratch

IFeatureSource fs = (IFeatureSource)ObjectFactory.CreateFeatureSource(conn, "OSGeo.SQLServerSpatial");
fs.SetConnectionProperty("Service", "(local)\\SQLEXPRESS");
fs.SetConnectionProperty("DataStore", "MyDatabase");
fs.SetConnectionProperty("Username", "mapguide");
fs.SetConnectionProperty("Password", "maestro");

where conn is an instance of the IServerConnection interface

Second way: Using the IResourceService

The GetResource method of the IResourceService interface automatically fetches XML content for the specified resource id and returns a strongly-typed IResource object.

Here's an example of fetching a feature source object

IFeatureSource fs = (IFeatureSource)conn.ResourceService.GetResource("Library://Test/Data/SQLServer.FeatureSource");


where conn is an instance of the IServerConnection interface

Final way: Using ResourceTypeRegistry

The final way is to use the ResourceTypeRegistry class to go from raw XML content to IResource objects and vice versa.

Here's an example of creating a feature source object from an feature source XML document on disk.

string xml = File.ReadAllText("FeatureSource.xml");
IFeatureSource fs = (IFeatureSource)ResourceTypeRegistry.Deserialize(xml);
fs.CurrentConnection = conn; //Need to assign a connection if you want to use any extension methods
where conn is an instance of the IServerConnection interface

And here's one example of going the other way, from feature source object to file

IFeatureSource fs = ...;
using(Stream sr = ResourceTypeRegistry.Serialize(fs))
{
using(FileStream fs = File.OpenWrite("FeatureSource.xml"))
{
Utility.CopyStream(sr, fs); //Or if you use .net 4.0 use the new CopyTo() method
}
}


So there you have it, 3 simple ways of working with resources in the Maestro API

Debugging with the Edit As Xml command in Maestro

Here'a a useful tip to assist in reporting bugs and debugging in Maestro.

At the heart of Maestro is the editors to let you edit the various types of resources that can be stored in a MapGuide Server. Now these editors are fully functional for most general cases, but should some part of a resource editor not work as advertised, here's what you can do.

Use the Edit As Xml command to view the XML form of the resource you are editing.


This command is not only convenient in that it allows you to bypass the editor and work on the actual XML content, if you know what you're trying to edit, but it also shows the xml content of the edited resource in its current state.

The resource editors in Maestro do not operate on raw XML content, instead they operate on a deserialized in-memory object form of that content. It is here that certain properties and attributes may be set incorrectly or missed due to bugs in the editor.

By invoking that command, Maestro is instructing the in-memory resource object to serialize itself back into XML, thus allowing you to see for yourself whether edits you have made in the editor have actually been applied.

This command has been very useful for me personally when implementing new resource editors or enhancing existing ones because the XML you see is exactly what gets sent back to the MapGuide Server when you hit the Save button, thus it has proven invaluable for me in debugging editor functionality and XML content model errors.

Friday, 8 July 2011

A bug reporting public service announcement

Ever get this error message in Maestro?

Object Reference not set to an instance of an object


This message and its exception type of System.NullReferenceException generally means that I (or a library I'm using) screwed up somewhere in the code.

However, just generally telling me this happened does not help me or you one iota because I require additional information:

  1. A stack trace of this exception message (so I can trace down the offending location in the code)

  2. The steps you took to produce this error (so I can construct the possible sequence of events and data that leads up to the offending location in the code)

  3. The data you are working with (where applicable)

Without these pieces of information, it makes it very hard for me to fix the cause of such errors.

The error handling in Maestro 3.5 now uses a more flexible dialog to display such exception information. Exceptions are now displayed in a more flexible dialog.


The message and detail components can both be copy/pasted or you can save the entire error dump to a text file and upload that as part an attachment to your trac issue, allowing for better quality bug reports.

However, what I have just explained doesn't just cover Maestro or this specific error. This is good practice for reporting bugs and issues in any application you use. Bad bug reports will most likely stay ignored because there is not enough information to work on. Developers are not psychic people, we need as much information as possible!

Providing at least the information as I've pointed out is a good start for any bug report and ensures that the developer can provide a suitable fix or workaround for you particular issue.

Wednesday, 6 July 2011

Announcing: MapGuide Maestro 3.5 beta 1

I'm happy to announce the first beta release of MapGuide Maestro 3.5

The significant new features of this beta are some new resource editors for:
  • Simple and Compound Symbol Definitions
  • Watermark Definitions
These editors are really rough quality at the moment and I would like feedback on these editors to see how the usability can be improved. Especially the Symbol Definition stuff as that has existed in MapGuide since 2007, but until now has not had a specialized editor due to the complexity of the XML schema.

If you need a refresher on Symbol Definitions and Advanced Stylization, here's a good starting point.

Other new features and changes include
  • Fusion Editor has been updated to use Google Maps V3. No more API keys required
  • The generated Web Layout for any resource preview includes a new command to report the map extents.
  • A more flexible dialog for error messages
  • Layer Definition editor has been re-structured to use less vertical screen space.
  • The usual assortment of bugfixes
This beta can reside side-by-side with older versions.

Download

Sunday, 3 July 2011

Book Review: OpenLayers 2.10 Beginner's Guide

This post is a review of the book: OpenLayers 2.10 Beginner's Guide

Many thanks to Packt Publishing for provding me a review copy of this book allowing me to write this review.

Relevance/Shelf Life

The problem with some technological books is that the technology advances at such a rapid pace that is renders the book's content out of date or obsolete after several months.

Fortunately, this is not the case with this book because the current release OpenLayers is still 2.10 and the OpenLayers APIs have been relatively stable that the content in this book is relevant enough for future releases of OpenLayers to come. In short, don't let the version number in the book title fool you, the book does have lasting relevance should you decide to revisit the content in this book in the future.

Content

The problem with writing a beginner's guide is, what level of knowledge do you assume the reader to have (if any)? If we were to take the book title at face value, then it assumes the reader has:
  • At least heard of a thing called javascript
  • Has used a web browser other than Internet Explorer.
Fortunately the book's introductory chapter covers the fundamentals of JavaScript, and all other foundational web development concepts (AJAX, JSON, Object Oriented Programming, etc) that eases you into to meat of the book: using the OpenLayers library to make compelling web mapping applications.

It is my own personal opinion that if you are to teach a newbie about web application development, they have to know what Firebug is and how to use it to simplify and optimize their web development workflow. I have stated in the past that if it weren't for Firebug (Ok. Let's extrapolate: If it weren't for modern web browsers like Firefox and Chrome), I wouldn't be in the business of doing web development.

Fortunately the book devotes an entire chapter to the Firebug extension for Firefox, which I believe should be a mandatory chapter in any book that delves into Web application development. In this respect, this book passes my newbie web developer test with flying colors.

So then comes the meat of this book: Using the OpenLayers library itself. The content is structured in a logical fashion, starting with getting a basic map up and running and then spicing it up with many different types of layer objects that you can add to this map (a single chapter is devoted to detailing all the available layer types you can add to your map). The important concept of projections is also significantly covered.

Another important aspect of OpenLayers is using controls to improve presentation and to add interactivity to your maps, and this book throughly covers the different types of controls available and how to use CSS to customize the style and appearance of these controls.

One last important aspect of OpenLayers is Vector Layers and the book covers all the intricacies of creating, styling and presenting Vector layers. (A sample chapter from the book covers Vector Layers)

The Web 2.0 ecosystem is an open-ended one where many different libraries and web services can talk to each other. OpenLayers is no different and the book clearly demonstrates the "Open" part of OpenLayers by showcasing how to interface and interop with third party libraries and web services. The book covers creating mashups with Google, Microsoft and Yahoo mapping services, as well as consuming photos from Flickr.

All in all, the content of this book does target its intended audience and does take care to not overwhelm the reader with OpenLayers API specifics, because that is what API reference documentation is for.

Verdict

This book lives up to the title. It is a comprehensive introduction to OpenLayers and web 2.0 application development. The chapter on Firebug alone is enough to guide new users to the proper path of web development, something I am thankful for, because I do get tired of giving the same "use firebug" response to mailing list questions over and over again!

Score: 8/10