Tuesday, October 28, 2008

Compiling libkml on Windows

Just a quick hint here for anyone searching for information on compiling libkml under Visual Studio. Version 0.4, which I just downloaded, won't compile the libkmlbase project unless you make a small modification to time_util.cc. Just change the order of the includes so that the winsock2.h include comes before the windows.h include. If you don't, you will get compiler errors such as, "error C2011: 'fd_set' : 'struct' type redefinition."

[[ UPDATE: Apparently there are other problems with using libkml in Windows. I just came across a linker issue where the symbol IsIconParent was undefined. To solve this problem, I had to add get_link_parents.cc and get_link_parents.h to the libkmlengine project and recompile. ]]

[[ UPDATE 5 Nov. 08: Both of these issues have been corrected as of version 0.5. ]]

Thursday, October 16, 2008

FalconView Open Source

Beginning with FalconView 4.3, FalconView will become an open source product.  Georgia Tech will distribute the code to FalconView to the general public, and installable binaries will be available.  The open source effort will include the main FalconView application and most of the overlays that come packaged with FalconView.

In order to accomplish this effort, we are reworking major parts of the FalconView architucture.  Historically, FalconView has included a standard set of overlays that built-in to the executible software and a set of "plug-in" overlays that may or may not be installed with FalconView.  Because some of the overlays are export-sensitive, all of the overlays for FalconView 4.3 will be pulled out and made into plug-in overlays.  This architecture will allow us to distribute a version of FalconView for the general public and a version of FalconView for the government.  The versions will be identical, except that the government version will include the threat overlay, the tactical graphics overlay, and some other components not available to the general public.

The FalconView team is excited about this effort.  We feel a great sense of ownership in our work and will be very glad to make the product available to a wider user base.  I'd expect that public betas of FalconView 4.3 will start hitting the internet sometime in the first half of 2009.  Stay tuned as for more news as events unfold.  Feel free to contact me for more details.

Wednesday, August 20, 2008

Geoprocessing in FalconView Using ArcGIS

I recently presented this paper at the 2008 ESRI User's Conference in San Diego. It's about much of what I've discussed on this blog recently, with some added technical details. Here are the slides from the presentation, in case you missed it.

[[ Note that the slides were originally generated in PowerPoint. I've uploaded them to Google for publication on the web. Some of the formating is a bit off, but they should get the point across. ]]

Friday, July 25, 2008

FalconView / ArcGIS 9.3 Compatibility Testing

I've just finished testing the FalconView GIS Overlay with ArcGIS 9.3 and I'm pleased to say that the testing went off without so much as a bump.

When we moved from ArcGIS 9.1 to 9.2, I found several incompatibilities in the FalconView 4.1 GIS Overlay that prevented FalconView 4.1 from working with ArcGIS 9.2. ESRI had changed the behavior of some of their objects so that we had to rewrite parts of our software to make it work with their new version. In my opinion, this loss of backwards compatibility moving between minor versions was a failure on the part of ESRI software engineering. This time, though, they seem to have gotten everything exactly right. Way to go, ESRI.

I'm very pleased that Georgia Tech will be releasing a version of FalconView 4.1 that is compatible with ArcGIS 9.1, 9.2 and 9.3. FalconView 4.2 will include compatibility with ArcGIS 9.2 and 9.3. For more information on these FalconView enhancements, e-mail me directly.

Wednesday, June 25, 2008

Using FalconView Geoprocessing to Find Communications Sites

This upcoming weekend is a special weekend for the amateur radio community. Field day (which would better be called Field Days) is a time when ham radio operators go outdoors to set up temporary communications stations to practice emergency communications preparedness and to have a fun educational and relational experience doing it.

I'm going to dust off my radio license (W4LL) this field day and hit the air with a friend in Colorado. We talked about several possible sites around the Boulder area where we could set up. One near the top of our list was Rocky Mountain National Park. Since there is a plethora of GIS data available for national parks, I decided to load some into FalconView and see if I could use it to help pick a site for us.

Here are some of the things we wanted in a site:
  1. Within the park.
  2. At a moderate altitude (not too high, not in a valley).
  3. Near a road so we wouldn't have to hike too far with our gear.
  4. On an area with level slope.
  5. An area with a good view of the sky (for radio propagation).
  6. Near a river or stream, if possible.
I loaded Colorado terrain data, RMNP road, stream, trail and border data and went to work. The simple way to do this kind of analysis is to make a group of raster data sets and score them based on a weighting of the criteria above. Adding all the scores together gives you an overall raster that scores the various terrains.

I won't go into too much detail here, but the ArcGIS analysis tools integrated into FalconView performed well for the task. The reclassify tool was used to score the terrain raster for altitude, the slope tool was used to get slopes from the terrain raster, the Euclidean distance tool was used for road and stream proximity data. Once some camp sites were picked out, the view shed tool was used to determine the sky visibility from the raster.

The first picture below shows some of the outputs from the aforementioned tools drawn in FalconView. The colors are so ugly because they represent a mosaic of different outputs which a human must interpret through careful visual analysis. (Honestly, without the table of contents, which shows up on the GIS Editor, the colors aren't very meaningful.)

The next picture shows just a camp site of interest, view shed, and terrain data, all drawn in the FalconView ArcGIS Editor.

Friday, May 23, 2008

Ensuring Release of COM Objects in a .NET FalconView Plugin

As any experienced FalconView developer knows, FalconView relies on Microsoft COM technology for our plugin APIs. To write a FalconView plugin, you implement a member of the ILayerEditor interface family and update the registry to tell FalconView the class to instantiate for the plugin. It's not hard to do once you've seen it done once. The FalconView wiki has a wealth of information on writing plugins.

FalconView 4.1, which is just now hitting the streets, includes the first .NET components ever to ship along with FalconView, including the 4.1 ArcGIS overlay. When I wrote the GIS overlay for FalconView 4.1, I discovered that the stack would become corrupted whenever .NET did its garbage collection. This would lead to instability which eventually made really bad things happen, such as FalconView disappearing from under a user's nose (one exception you may see is ReportAvOnComRelease). After some research, we discovered that this was because .NET was trying to garbage collect COM objects that had already fallen out of scope in FalconView. The trick to fixing the problem - and if you're writing a .NET plugin for FalconView 4.1 this is very important to pay attention to - is to release explicitly the FalconView COM objects once you're finished with them. The following code block, by making use of finally clauses, provides an example of how to ensure the release of your COM objects, even if your routine exits early via a premature return statement or an exception. (See the Hello World example on the wiki for the full project containing this example.)

public void OnDraw(int layer_handle, object pActiveMapProj, int bDrawBeforeLayerObjects)
{
try
{
if (bDrawBeforeLayerObjects == 1)
{
IActiveMapProj pActiveMap = (IActiveMapProj)pActiveMapProj;

try
{
ISettableMapProj pSettableMapProj;
pActiveMap.GetSettableMapProj(out pSettableMapProj);

if (pSettableMapProj != null)
{
try
{
IGraphicsContext pGraphicsContext;
pActiveMap.GetGraphicsContext(out pGraphicsContext);

if (pGraphicsContext != null)
{
try
{
// ... Draw Here ...
}
finally
{
Marshal.ReleaseComObject(pGraphicsContext);
}
}
}
finally
{
Marshal.ReleaseComObject(pSettableMapProj);
}
}
}
finally
{
Marshal.ReleaseComObject(pActiveMap);
}
}
}
finally
{
Marshal.ReleaseComObject(pActiveMapProj);
}
}


Note the use of the nested try ... catch ... finally blocks. This ensures that the COM objects will be released before execution is returned to FalconView.

(In this example, I show each try block explicitly, which has the benefit of constraining the scope of objects. One could make this code more readable by avoiding the nested blocks of code and containing each Marshal.ReleaseComObject call in one big finally statement. As this big finally block could be entered from any point in the try block, this would simply require null reference testing on each COM reference before attempting to release it.)

For developers writing .NET plugins to FalconView 4.2, which is nearly ready for beta release, there is same good news here. The lead FalconView technical guru just informed me this week that FalconView will manage COM objects on the heap, paying full attention to reference counting to prevent premature disposal of the objects. Though this means that explicitly releasing COM objects in you .NET code is no longer required, it is still a nice idea to do so as it allows FalconView to dispose the object without having to wait on .NET garbage collection.

Tuesday, May 6, 2008

ArcGIS Programming Trick: Adding a Legend to a Raster Renderer

In the previous entry on creating a DTED mosaic in the FalconView ArcGIS editor, I touched on creating a RasterStretchColorRampRenderer to symbolize the output of the DTED mosaic. This post is a short extension of that entry. One detail that we discovered in implementing the renderer is that the color ramp did not draw on the table of contents legend. It turns out that there is a trick to getting the color ramp to draw. As far as I can tell, this trick is undocumented on EDN, but we learned it through the help of an ArcGIS guru at ESRI.

There are two things that need to happen for the legend to be created, neither of which we were doing. After instantiating the RasterStretchColorRampRenderer, it is important to associate the raster we are rendering with the renderer and to call Update on the renderer immediately thereafter. The code in the previous blog entry must be changed to look like this (the highlighted code is new):

// Create a renderer to be used with the raster layer

IRasterStretchColorRampRenderer pRasterStretchColorRampRenderer = new RasterStretchColorRampRendererClass();
IRasterRenderer pRasterRenderer = (IRasterRenderer)pRasterStretchColorRampRenderer;

pRasterRenderer.Raster = pRasterLayer.Raster;
pRasterRenderer.Update(); // the call of Update right after setting Raster is important

pRasterStretchColorRampRenderer.BandIndex = 0;
//...


In this case pRasterLayer is created in the same way as before, except we moved the block of code that creates the layer earlier in the raster creation procedure.