Linking C++ and JS with PYTHON

involving QGIS C++ APIs, PyQGIS, QWebKit and PyQt

Case study: Geosisma a QGIS plugin


Who am I

15 year working on Spatial Ground Segments
Landsat, Cryosat, MODIS, Sentinel...

Since 2006 in QGIS/GRASS

QGIS Core developer
WMS Legend support in legend and composer
Saving style in Spatialite
Add SVG support to Mapserver/SLD interface
Bug fixing
Plugin porting and developing

Founder of GFOSS.it
Italian OSGEO Local Chapter

Co-Author of Mastering QGIS
















Reviewer for

QGIS Python Programming Cookbook
















QGIS (mainly C++)

QT  (C++)
http://qt-project.org/

SIP (Python2C++/C binder)

What is QGIS


Geographic Information System

What is Geosisma


Online/Offline Earthquake Damage Inventory Tool

Offline Functional Specifications 

  • Cache preparing integrating other project code

  • Download "Requests" based on User Credentials using REST APIs

  • Fill "Safety report" with "Request" data

  • Associate Cadastral Polygon to "Safety report"

  • Edit Cadastral Polygons

  • The same  Online behavior (zooming, auto-complete, data validation)  

  • Upload "Safety reports" and cadastral poligons using public REST APIs



I'm a lazy developer


reuse, reuse, reuse,  reuse,  reuse,  reuse,  reuse          

What About HTML5?


Main usable feature for Geosisma Offline


  • Caching (Offline capability)

  • Persistence (Session and Local storage)

  • Platform Independent


Re-use Online Form


  • Created using Django
  • Complex specification (Form validation and logic)
  • Re-using final form rendering
  • Minimal modifications
  • Follow evolution (next will be mobile)

....SO....

Insert the Online form inside QGIS

...Brighton 10th QGIS Hackfest...


"first" (secret) prototype

tech available since 2011

QgisD3 by Luca Casagrande


QgisD3 Python Plugin

a never published plugin

The architecture

Container

  • Instantiate WebView

  • Configure WebView (QWebSettings)

  • Instantiate Bridge class

  • (optional) add listener to Bridges's events

  • Inject Bridge in JS (addToJavaScriptWindowObject)

  • inject JS code to evaluate (eg. a JS bridge methods - evaluateJavaScript)


WebView2Container Bridge


  • Def PY slots called by JS
        @pyqtSlot(<params definition>)
        def slotName(self, records):

  • (optional) define out signals - pyqtSignal()



WebView (JS)


sourcing JS bridge (Container2WebView bridge)

Results

Luigi Pirelli

luipir@gmail.com - @ginetto



Work committed by: Faunalia (www.faunalia.eu)
Licence: (CC BY-SA 3.0)

QGIS: Linking C++ and JS with Python

By Luigi Pirelli

QGIS: Linking C++ and JS with Python

"Geosisma offline" is QGIS plugin in which Python is used to link QGIS(c++) with web technologies (JS). Main tech used involve C++, Qt, PyQT, SIP, PyQGIS and QWebKit

  • 3,103
Loading comments...

More from Luigi Pirelli