Discussing Cricket with an Alaskan

Whilst this post might have more to do with a game played with leather and willow to a guy who lives in a part of the world that could only accommodate ice cricket for most of the year, well to be honest the UK isn’t much better for cricketing weather either but that’s beside the point, it’s actually about this years ESRI’s Developers Summit which I was lucky enough to attend this year in Palm Springs.

To ArcGIS 10 and beyond!

image The 2010 #DevSummit was a cornucopia of new technologies and online systems rolling out towards the release of ArcGIS 10. Even though I work for a distributor there was still lots of new stuff to see especially around the online world through use of Amazon for hosted ArcGIS Server (pricing to be confirmed), you can see an overview imagefrom the Business Partners Conference here and the development of the aforementioned arcgis.com (currently not accessible, but will be real soon and has the new ArcGIS Explorer Online) which you can see two videos of here (BPC) and here (DS).

The iPhone SDK got quite a lot of slide-time in both the plenary here as well as a number of sessions. I wanted to make time to have a look, I have an iPhone but no Mac, but there were so many other interesting sessions that I never had a chance, although I can now catch up online.

Online all the time.

Due to the nature of today’s internet the videos of the developers summit were online before my flight had dropped me back at Heathrow. So you too can follow mostly the same schedule that I followed, minus the face to face discussions with Development leads, Service Leads, Product Managers and other Distributors that make conferences like these invaluable and allow you to plan your development strategies for months to come. Some of the sessions I say were as follows.

  • The plenary : lots of videos here. Digs into all the different areas of the upcoming product.
  • Using the ArcGIS Server REST API’s : I can’t get enough about the REST API, the variety of new geometry functions provided
  • An Overview of the ArcGIS API for Microsoft Silverlight/WPF : I’ve been doing lots of Silverlight development recently and whilst many of the cool kids went to the Flex sessions, I checked that I wasn’t doing anything insane by going to some of the Silverlight ones.
  • Python Scripting for Map Automation in ArcGIS 10 : I like the way you can analyze map documents using arcpy! In fact I like most of the stuff you can do with arcpy, now if only someone would write me an avenue wrapper for it and I’d be good.
  • Advanced Map Caching Topics : Lot’s of tips about how to create efficient caches, how caches will change in ArcGIS 10 and the new mixed mode image format, watch and cache.

Unfortunately some of the interesting ones aren’t up there yet, especially the one from the prototype lab with Augmented reality and Microsoft surface demo’s which looked quite slick (and had one of the biggest overhead camera’s I had ever seen), David Chappell’s keynote going through Cloud Platforms (a must watch if you haven’t heard him go through this before) and finally there was another Silverlight session where they showed Windows Phone 7 integration with the Silverlight API. If I see them post them online I’ll update the list above.

So what’s with the title?image

Anyway the title of this piece is all about the benefits about attending a conference far away from home, the opportunity to talk to people face to face about technology, something that is not possible when your watching the talks over the internet. In this case, we were out for dinner one night, when a colleague turns up with some poor unsuspecting fellow he’s imagemet at the conference (@jdoneill from Girdwood, AK), as is the way with conversations with me the subject turned on to cricket and then the floodgates opened.

Although we never did discuss the merits of leg theory I did try and cover all the other aspects of the game, he even managed to seem interested for most of the conversation as well, he was a baseball fan so the compare / contrast, mutual appreciation of each others stat laden sport ensued. If you ever want to image read such a comparison from an English point of view then I’ll point you to this book.

As an aside we won’t mention about the guy he turned up with the next night. Remember, what happened in Palm Springs, stays in Palm Sp
rings, well apart from the technical information that is.

The web world is (mostly) flat.

It might come as a shock to many of you, but often on the internet the world is flat. Yes I know that you thought this whole debate had gone out with the ark (or actually a little later), but after years coming to imageterms of the world being a sphere, cartographers everywhere needed a method of putting that world  down onto paper.

Now this was fine for many years until 2nd May 2000 the US decided to turn off Selective Availability and whole world seemingly brought into WGS84. The difficulty here though is the fact that WGS84 and Longitude and Latitude coordinates are an approximate representation of the position in the real world, geographic coordinates, many maps paper and web based are representations of a flat world using Cartesian coordinates.  

A world of BNG

Obviously as a GIS professional you know all this, although come to think about it, a lot of people in the UK probably haven’t. Why, I hear you cry? Because the Ordnance Survey in its role of national owner of all things spatial in the UK decided that we needed a more accurate representation of the surface of the United Kingdom (fortunately we are not a large county, well unless you measure it in ego image terms, so it can work quite well for us). In doing this they created the British National Grid (BNG) which allows them to produce all of their excellent paper maps (and not paper globes which would be inconvenient for packing up in your rucksack).

Now why do I mention this, well for the first three years of my work at ESRI(UK) I touched nothing else but data in the BNG projection, it was only when I needed to implement a solution using GPS data for tacking refuse trucks that I came up against the need to occur re-projecting data between two projection systems WGS84 (for GPS) and BNG (to plot on the web map).

Whilst BNG is the preferred coordinate system for many users of OS data, amongst many web developers who have come across mapping via the various web offerings of Microsoft, Yahoo and Google (or indeed in the past with ArcWeb Services) the coordinate system they use will be Web Mercator. In fact in the UK there is a chance now that more people use the Web Mercator projection than the BNG projection, a fact that shouldn’t be lost on people. So where was I? Ah yes setting the stage for my problem.

What was I doing?

The reason why I came to this post was the fact I was implementing a little demo for a colleague to show a GeoRSS feed of Earth Quakes (what I term a ‘classic feed’ as it appears in every demo) with the Bing map service, both within the ArcGIS Silverlight API. I thought that this would be no problem as I knew of two existing ESRI demo’s with the functionality I required in. Firstly the GeoRSS layer sample from Morten and the Bing sample from the ArcGIS Silverlight concepts section.image

Now using my advanced skills in copy / paste I managed to get a map that looks like this (image right). The classic, “everything is off the equator near africa” map. Hmm, I think, when i was using the old ArcGIS Services map (as per the sample) I could get an image like this (see below).

imageAh-ha I think, something is up in the state of projections. How can I request the GeoRSS feed in another projection, in this case Web Mercator, rather than the Long/Lat WGS projection that was given as standard.

The answer to my ponderings was that GeoRSS defines the returned format as having to be WGS84 and in order to place it on top of my Bing map I would have to re-project the data myself. Fine I thought, I know how to do that, ArcGIS Server doesn’t have a Geometry Service for no reason you know.

Chatting with the Geometry Service

With the implementation of the Geometry service within ArcGIS it’s been very easy to re-project data between coordinates, you can find the documentation to do this here. This is good as it allows you to project between many different coordinate systems as it’s all server bound you don’t need to pollute your client with any algorithms.

It should be noted here, that over time there have been a number of SRS’s used to define Web Mercator. An email that I’ve seen on the boards which explains the differences between the numbers used can be found here (see the post by Melita Kennedy).

The problem you have is that it can be rather inefficient to get points into the client and then send them to another service to project, get the data back and then have to display that in the map. This solution might be the most flexible (as it could possibly handle any projection required) but it leaves a bad architectural taste in the mouth.

I put it to the back of my mind in the folder entitled, architectures to use when other methods fail and went on thinking about how it might done, back to math (+s for UK readers).

An Algorithm

I’ve always wondered what the actual algorithm used for doing the projections between WGS84 and Web Mercator, this was a demo so I didn’t have to be too careful about the accuracy. I once again used my Google brain to come up with the following link which contained a Python script which contained the algorithm a required. Which when converted to C# (not too hard) looks like so:

image

When I placed this into my GeoRssLoader.cs class file (see the GeoRSS Silverlight sample again) then I managed to get the points placed into the correct position, see map below.

imageSorted I thought, but then I got thinking. Surely this is an amazing common task that everyone is doing, GeoRSS is very popular and there are one or two ESRI developers out there (I know I have 250+ of them coming to see me present at our Developer Hub Conference next week).

If you’re interested in converting between WGS84 and OSGB36 then this link should be handy, if I get time I’ll knock up a C# class doing it and post it on this site somewhere.

The Easy Way

So I was showing my solution to another colleague of mine all impressed that I could do it using the power of math when he said that the JavaScript API had a function for it built in called esri.geometry.geographicToWebMercator(). Gah! I thought, all these JavaScript dudes have it so easy, no one ever creates one of these for us poor Silverlight chumps. Well actually they do.

Hidden away in the ESRI.ArcGIS.Client.Bing.Transform class are the following two methods:

imageBoth of which much simpler than including your own projection algorithm within your code, why reinvent the wheel after all. As we can see there are always many ways to do things with technology. It’s often the simplest one that can avoid notice when your thinking through a problem, although it should be said that there are merits to all approaches due to flexibility (REST Service), transparency (algorithm) or simplicity (existing class), the choice as they say, is yours.

Adventures through the Silverlight

imageOver the last few weeks I’ve been having a few adventures in the world of Silverlight. A bit like Alice I’ve been following white rabbits down holes and through looking glasses. What I’ve discovered is that having an IDE doesn’t always make things easier, especially when the error is occurring somewhere between the chair and the keyboard, a place which is notoriously hard to debug.

Brain don’t fail me now

One issue I have is with my brain. If you start thinking as if the development environment is going to help you, then when it doesn’t it can completely throw the processes you use to figure stuff out, if indeed you can figure it out. Strangely enough (well for me anyway) if I’m in an environment where there is little help, read ‘no intellisense’, then my brain rewires itself for self help. This can often be easier on the development as I tend to check the code more and be more robust my development methodologies (i.e. checking my environment is setup correctly for one thing). Usually I find the differences in coding for Silverlight or using Dojo to follow these patterns (I often still use VS for Dojo, but obviously get precious little help!).

With Silverlight my development is all done in Visual Studio 2008 (with some design done in Expression Blend of course). Now 2008 is quite helpful when checking the syntax of C# code, but it can come off the imagerails with the XAML syntax, so once your done in blend and are hacking around with the mark-up you can often come unstuck. Many the time I’ve spent at the top of the page.xaml tinkering with the namespaces, wondering why the code wont work when I’ve copied it straight from the ArcGIS Silverlight API samples (note: always check the breaking changes in any of the API release notes like here as the samples sometimes lag behind the releases and don’t always correspond).

Other times the IDE just goes a bit spooky on you, such as when I added a new class to the top of my page.cs file (don’t ask me why I wasn’t refactoring things into different places, I was prototyping it’s allowed). Now I figured that this wouldn’t have been a problem, I’ve often slung a class at the top of a file and had no problem (or none I can remember!), but whilst the compilation and run of the application had no problem, the actual linking up of the page.xaml and the page.cs seem to have been b0rked.

Every time I needed to add a new event handler, or to navigate to an existing handler from the XAML to the code I would get the following error:

To generate an event handler the class ‘page’ must be the first class in the file.

Now I didn’t believe what my eyes were reading at first, of course I was using Visual Studio so my brain had partially shut down, therefore using my outsourced brain (read Google) I spent a few minutes imagetrawling the interweb in the hope of finding a solution. I did find it buried deep down in the following thread, where it spelt out the reason for my ‘code fail’ to be the fact that my new class was first in the code behind file, move the class to the end and hey-presto everything was tickety-boo.

Now this serves to highlight both my initial problem of my brain expecting simple issues like this to be sorted out by the wonder that is Visual Studio 2008 and secondly highlighting the fact that whilst an order of magnitude better than Visual Studio 2005 for its integration with Silverlight, it wont be 2010 that Microsoft will have a true development environment for it. Note to self, better get installing the 2010 RC when it’s released next month to check life will be peachy.

A Dash or Two

Where Silverlight (or any RIA environment, Flash, HTML 5) really excels is in the delivery of dashboards that allow for the easy cognitive processing of information without the clutter of hardcore GIS tools that are often prevalent in some internet mapping applications.

Indeed in my opinion (not necessarily anyone else’s though) if your using Silverlight to just deliver Y.A.M.A. (Yet Another Mapping Application) then unless you really need it to be rotating on a flying cube surrounded by dancing leprechauns (however tempting it might be) then you probably need to be using a more standard HTML/JavaScript based client, such as Dojo which doesn’t have the plug-in overhead.image

The ability to present and link multiple maps together, all updating in real time, with graphs and reports can really help sell the benefit of GIS to upper management, who often don’t get excited about data formats, tile caching and the different API’s. Show them the ability to visualise all their assets and modify their assignment in real time allowing for visual modelling of costs, then you might be on to a winner, show them the common operating picture of an unfolding disaster then you almost certainly are, especially if it can save money in the long run. Sure it might use all of the cool technologies under the hood, but most people who make decisions don’t care, they want simple tools that can leverage powerful geoprocessing tasks without even noticing. With good design and the interactivity given by Silverlight (and other RIA’s) then the move of GIS from allowing people to make niche decisions to impacting throughout the business should become a whole lot easier to show and use.

imageLet me at it – hold the white rabbit

Hopefully you can see not only the wonderland that can be offered by Silverlight but also the frustration that can occur if you blindly follow white rabbits around whilst developing.  If you don’t have time to build your own Silverlight client from scratch, you can always get a head start from one of the example applications fro
m the community section of the Silverlight resource center here or some nice examples of dashboards and UI can be seen on the ESRI North East Africa site here.