Thursday, May 9, 2013

FalconView is Going 3D

Starting with FalconView 5.2, users will have the option of viewing data in 3D.  Our engine uses osgEarth to render FalconView maps on overlays on a 3D canvas, draped over elevation data.



We probably won't have a beta of this available until later in the year, but stay tuned the the official FalconView web site as we push out code and releases.

Friday, March 22, 2013

A Random KML Generator

For testing KML performance in FalconView, I've written a Random KML Generator.  It only does points and squares at the moment, but I will be adding to it over time.  Feel free to make good use of it.  The source code is on the FalconView web site here (forgive the monolithic Python file).

Monday, January 28, 2013

Quantum GIS KML Overlay

I've put together a KML Overlay for Quantum GIS based on the KML Overlay that I'm working on now for FalconView.  You can see a video demonstration of it here.  The source code is here.

My purpose in posting this is to demonstrate a KML drawing library that I'm putting together that is intended to be a rendering companion to LibKML.  More about this drawing library, which is currently under construction, will be posted here.


Friday, January 18, 2013

How to Create a QGIS Plugin in C++

FalconView has a rich plugin-architecture that I've been writing to for many years. Though I'm very comfortable writing FalconView plugins, I'm in the process now of writing a plugin that needs to work in FalconView and in Quantum GIS.  This post is about my learning experience in writing a plugin for Quantum GIS.  I find that the documentation on QGIS plugins is sparse, so perhaps what I've learned will help others who want to do something similar.

The full source code for this plugin may be found here.  This is a minimalistic plugin that simply draws a rectangle on the screen using screen coordinates.  It demonstrates how to register a plugin with Quantum, how to add an action to a QGIS menu, how to register to receive a callback, and how to draw on the map canvas.  I call it the Hello World plugin.


(Before I started this process, I had no experience coding to QGIS or to Qt.  I'm sure that some of what I've done here does not reflect best practices with either technology, so I invite members of either community to comment here in order to help me and others to understand best practices.  I will note that my plugin does not conform to the Quantum GIS coding standards. Instead, I've conformed to the FalconView coding standards since this project is part of a larger effort related to FalconView.)

[[ EDIT: Most QGIS plugins are done in Python, and there is much better documentation for these plugins. ]]


The Header File

The complete header file may be found here.  There are two things of interest in the header file.  First, notice that the HelloWorldPlugin is a QObject.  This comes by deriving from QObject and by including the QOBJECT macro in the class.


class HelloWorldPlugin : public QObject, public QgisPlugin
{
   Q_OBJECT
...

The next point of interest is the declaration of the Qt slots.  These are callback methods.

public slots:
   void StartOverlay();
   void DrawOverlay(QPainter* painter);

Functions Exported from the Library

There are a handful of functions exported from the library that are required for QGIS to load plugin.  These are all in the cpp file, and are all declared with the QGISEXTERN macro.

Adding a Menu Item to a QGIS Menu

We do this in the initGui method.  The important thing to note is how we register for a callback using connect(...) and how we call into the QGIS interface to add the action to the Plugin menu.

/*virtual*/ void HelloWorldPlugin::initGui()
{
   std::cout << "HelloWorldPlugin::initGui" << std::endl;

   // add an action to the menu
   m_action = new QAction(QIcon("" ), tr("Hello World"), this);
   m_action->setWhatsThis(tr("Draw on the map canvas."));
   connect(m_action, SIGNAL(triggered()), this, SLOT(StartOverlay()));
   m_qgis_if->addRasterToolBarIcon(m_action);
   m_qgis_if->addPluginToMenu(tr("&Hello World"), m_action);
}

Handling the Menu Item Selection Event

StartOverlay() handles this event.  It gets the map canvas and connects to the render complete signal.  I have some code in this sample that demonstrates how to zoom out the map.  This is not necessary for drawing the rectangle, but I've left it in for pedagogical reasons.

void HelloWorldPlugin::StartOverlay()
{
   std::cout << "HelloWorldPlugin::StartOverlay" << std::endl;

   // get the map canvas
   QgsMapCanvas* canvas = m_qgis_if->mapCanvas();

   // connect to the render complete signal
   connect(canvas, SIGNAL(renderComplete(QPainter*)),
      this, SLOT(DrawOverlay(QPainter*)));

   // zoom out for fun
   canvas->zoomOut(); // wheeeeee!!!
}

Drawing the Rectangle

Now that we are registered to receive calls to DrawOverlay when the canvas refreshes, drawing the rectangle is easy.

void HelloWorldPlugin::DrawOverlay(QPainter* painter)
{
   std::cout << "HelloWorldPlugin::DrawOverlay" << std::endl;
   painter->drawRect(20, 20, 60, 60);
}

Building the Project

The Qt project file is here.  First, run qmake qgis_hello_world.pro to make the Makefile.  Next, run make to build the library.  Notice that Qt will generate some code files that you will find in the project folder.

Trying it Out

Copy the library to your QGIS plugins folder.  The command that I use to do this on my Ubuntu system is sudo cp libqgis_hello_world.so.1.0.0 /usr/lib/qgis/plugins/libqgis_hello_world.so.

The Hello World plugin should now appear in the QGIS plugin manager menu.  Turn it on.  Next, select the menu item that we added to the Plugin menu.  The rectangle should draw.

Finding More Help

Be sure to look at the QGIS header files (in /usr/include/qgis on my system) and API reference (http://www.qgis.org/).  Also the samples under src/plugins are helpful.


Thursday, November 1, 2012

Open Street Maps KML Super Overlay

In support of testing KML in FalconView, I created a simple Google App Engine application that provides automatically generated KML via network links and regions to deliver Open Street Maps.  I thought this was fun enough to blog.  You can find a KML file to try it yourself here, and you can find a link to the Python source code here
.


Friday, April 1, 2011

FalconView Announces FalconView for Facebook

ATLANTA, GA - In an effort to bring a more social experience to the mission planning community, FalconView researchers have completed a year-long effort to integrate two of the most popular and useful tools in the DoD mission planner's kit: FalconView and Facebook.

"The idea is to make mission planning more people-oriented, more social, and more fun," said FalconView program manager Chris Bailey.  "This will take us beyond just icons on a map.  FalconView for Facebook will add the human dimension to the experience.  Intelligence analysts who have long desired better integration between geospatial intelligence and human intelligence have their wish."

One of the features of FalconView for Facebook is the ability to open a target's Facebook page from within the FalconView GUI.  Bailey demonstrated this feature to us in the lab by linking FalconView to a live intelligence feed, right-clicking on a combatant radar site, and opening the "Facebook places" page for the site, where he pointed out that several combatant soldiers had already "tagged" themselves in the satellite imagery of the location.  (Security concerns preclude us from posting the actual demonstration in this article.)

Where could this project lead?  "I can't disclose all of the next steps," said Bailey, "but let's just say that geographic analysis of your Farmville properties will soon become much easier."

More details about this project may be found here.