[pgrouting-dev] [SoC][pgRouting] GSoC 2018 Final Report :Making pgRoutingLayer plugin compatible with the new version of QGIS and add GUI support for proposed functions.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[pgrouting-dev] [SoC][pgRouting] GSoC 2018 Final Report :Making pgRoutingLayer plugin compatible with the new version of QGIS and add GUI support for proposed functions.

Aasheesh Tiwari

Making pgRoutingLayer plugin compatible with the new version of QGIS and add GUI support for proposed functions.


Google Summer of Code 2018

Abstract

pgRoutingLayer is a plugin for QGIS that serves as a GUI for pgRouting which is a popular routing solution for PostGIS database. The plugin is written in python . It uses SIP to create python bindings for C/C++ libraries, pycopg2 for interacting with PostGreSQL. Internally pgRoutingLayer uses pgRouting to provide geospatial routing functionality.

Architecture of pgRoutingLayer

A python plugin for QGIS must have the following files:

init_.py : The starting point of the plugin . It has the classFactory() method which makes it known to QGIS . It receives iface (instance of QgisInterface) which is used to interact with QGIS environment.init.py returns an instance of our plugin. It also has other initialisation code.

metadata.txt : It contains general info , version, name and some other metadata used by plugin’s website and plugin infrastructure.

UI file : It stores the user interface configuration for ther plugin, saved in a XML format. It contains definitions of Qt widgets with slots and signals. There are two ways to use this file , one is to include the file with the app and render and parse it directly at runtime using uic . The other way is to compile the file into python classes and include it in the python source files. pgRoutingLayer plugin uses the first approach.

Resource file : It contains the resources needed by the plugin like icons,translation file etc. It is an XML based file that lists files on disk and assigns them a resource name that the application must use to access the resource.

pgRoutinLayer.py : It contains the python code that actually defines the functionality of the plugin. The pgRoutingLayer plugin breaks the large code of main.py into modules that are manageable and easy to understand . Below diagrams introduces the names of files and their dependency.

screen shot 2018-08-13 at 2 09 49 am

pgRoutingLayer before GSoC 2018:

In 2018 QGIS released QGIS 3.0 which introduced an API break for existing plugins including pgRoutinLayer.The key changes in QGIS 3.0 are as follows:

  • Updated from Qt4 to Qt5
  • Updated from PyQt4 to PyQt5
  • Updated from Python 2.7 to Python 3.0
  • QGIS API is improved , many classes have been deprecated or renamed.

The above changes have implications that the pgRoutingLayer plugin is no longer compatible with QGIS 3.0 . The aim of this project was to make the pgRoutingLayer plugin compatible with the new version of QGIS. Another objective was to add functionalities for the proposed functions which are to be released with the next mayor release.

Status of plugin in QGIS 3.0 before GSoC 2018

screen shot 2018-08-13 at 6 24 17 am

Changes through this project:

As can be seen above there were 4 major issues which needed to be addressed in order to make the plugin compatible. I followed the below tasks :

  1. Ported the plugin from python 2.7 to python 3 . For this, python future library was used. No library can give perfect result, so after that manually made corrections to the code which the library had wrongly ported.
  2. For making Qt4 to Qt5 conversion, changed all the renamed classes, removed all deprecated classes and replaced them with new equivalent classes, made changes according to the new classes.
  3. For PyQt4 to PyQt5, the same above process was done.
  4. Major part of the code uses QGIS API which was changed. So the task was to use the new QGIS classes in the code. QGIS community has released 'QGIS API break' document which contains all the changes made in the new API. So changes to the code were done by following the API break document. This was the most crucial part and also the most time taking part. For every removed class, I had to find an equivalent class and make changes in the code for new class. For every renamed class, needed to change all the code with new class name.

The above 4 steps were refined again and again until the code worked.

The second part of the project involved making the plugin ready for the next major release of pgRouting. First removed all the functions which are going to be deprecated. Next task was to make changes in the plugin to accept new parameters for the upcoming functions. So GUI changes were made. Now code was written for new functions which involved sql queries and drawing the output. Due to time constraints only 2 functions could be coded. These functions were unstable so I merged the code into a new branch. Finally documentation for the code and unit test for some files has been written. The final status of plugin is that it works in QGIS 3.0 There are some funtions like pgr_Ksp which needs improvement.

Final Status of Plugin in QGIS 3.xx : Works Perfectly !!

screen shot 2018-08-13 at 6 42 32 am

Future opportunities:

pgRouting has a vast collection of stable functions(probably made by previous GSoC students). These functions need to be present in pgRoutingLayer plugin so that QGIS users can be benefitted. For this we need to add more functionality to the plugin. This is a task on it's own so it may be a potential topic for GSoC 2019.

Let's see some examples

Link to presentation

Link to project's OSGeo wiki:

Wiki

Link to project code:

Link to commit history

All the changes made by me during GSoC 2018 can be followed through the below link, which directs to commit history. Commit history

What's left?

  • Tsp function gives the output but it is not rendering.
  • Ksp function needs improvement.
  • Trsp works fine but they are complex to use and tooltips are not well written.

Best Regards,
Aasheesh Tiwari
MTech | CSRE
Indian Institute Of Technology Bombay


_______________________________________________
pgrouting-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/pgrouting-dev