ESRI’s ArcGIS Explorer (AGX) is a free downloadable GIS viewer which allows viewing of a wide variety of spatial data in either 2D or 3D (Globe) display modes. In Exprodat’s R&D team we’ve been working with the AGX Software Development Kit (SDK) for a few months and have been impressed with what you can do, out-of-the-box. Naturally some tasks require you to do a little more work, and the one we’ll describe here is one of those.
A colleague needed to place a geological section in an AGX presentation, in its correct orientation, and asked for our assistance. He could have done it in Google Sketch-up, but we thought that we could probably create a tool in AGX that would allow us to do it more easily, and repeat the operation whenever we wanted. He supplied us with an example section, as a KML file, that referenced a COLLADA model. We’d vaguely heard of COLLADA (it’s basically an XML schema that enables the definition of 3D models) and took a quick look at the reference manual, and the example section.
One of the many things that COLLADA allows you to do is to define a mesh onto which an image is applied. The simplest mesh onto which a rectangular planar image can be projected is rectangular – i.e. defined by 4 corner points. These corner points are defined by X,Y,Z coordinates, meaning that the mesh can be oriented as required. Looking at the example file, we found that the KML file that referenced the COLLADA .dae file contained a Lat-Long insertion point, some orientation information and some scaling information. This allows the COLLADA model to be inserted, rotated and scaled to meet requirements.
Having worked out how the example file worked, we designed a tool, based on an AGX dockable window, to allow the user to drag out a line representing the section. We added editable text boxes to the window, which we populated with the start/end XYZ values for the section, allowing the user to fine-tune the section placement. We wrote, with help from the internet, some code to calculate the bearing of the line. We then added file selection controls to allow the user to pick an input image and an output KML file (which needs to be placed in a subfolder, as the KML file references files placed in subfolders).
Having created the basic user interface and some of the more generic code, we then worked on the code to actually do the work. It occurred to us that it might be easier to scale the model directly in the COLLADA file, by scaling the mesh, and then handle the rest of the work in the KML (the insertion point and orientation). To do this, we extracted the input image width (by loading it as a System.Drawing.Image and then looking at the width property), then used the length of the line the user had defined to calculate the scaling. We then wrote a COLLADA writer class to generate the .dae file, which we stored in a subfolder called models, mimicking the structure of the models exported from Google Sketchup. The image was copied across to a subfolder called images and then the KML file was created in the main target folder.
We gave the tool a spin and noted that the far end of the section (away from the insertion point) ‘stuck up’ in the air. A quick think made us realise that this was due to the earth’s curvature – the earth’s surface drops away from the base of the section. In order to correct this in a ‘quick and dirty’ fashion, we worked out a routine to drop the far end of the section by the height that it was initially above the surface. Doubtless COLLADA would allow us to do this more elegantly, fitting the base of the mesh to the surface as we went, but that’s something for another day.
So, there you have it, a tool that allows you to place sections on AGX in their correct orientation. Note that you can amend the Z-value of the insertion point to drop the section below the surface, although this then leaves you with the problem of how to actually see it (see the attached documentation for some tips about how to do this).
COLLADA looks like it has some legs for GIS, allowing you to create a single complex model which you can then position and orientate to meet your requirements, allowing the construction of animations and the like (or a simpler version of the Enormous Arrows tool that we’ve previously blogged). We’ll be investigating these possibilities over the coming months and will be posting examples and samples as we create them.
Posted by Ross Smail, Head of R&D, Exprodat.