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++)
http://www.riverbankcomputing.com/software/sip/intro
PyQt (SIP bind to QT)
http://www.riverbankcomputing.com/software/pyqt/intro
PyQGIS (SIP bind to QGIS)
http://www.qgis.org/en/docs/pyqgis_developer_cookbook/
PyQt (SIP bind to QT)
http://www.riverbankcomputing.com/software/pyqt/intro
PyQGIS (SIP bind to QGIS)
http://www.qgis.org/en/docs/pyqgis_developer_cookbook/
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
credits: Anita Graser: http://www.flickr.com/photos/48244569@N02/9930490423/in/pool-2286344@N25/
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
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
- 4,121