Monthly Learnings in Google Summer of Code 2020

Mapping my Journey through GSoC’20 — Flight.

My Second Month as a Student Software Developer!

Aryan Gupta
6 min readJul 30, 2020

--

Hello Readers!

(I am Aryan Gupta, developing the MSS Software under Python Software Foundation through Google Summer of Code, 2020. To know more about my organisation and project, read here. And you can find the First month learnings here.)

My last post (and month) ended with me finally able to display multiple KML Files on a single map.

Multiple KML Layers on a single map.

This was a huge confidence booster for me, since at the very start, I had no idea how I would ever be able to do this.

But, working on the software, understanding it, getting to know the ins and outs really paves the way through to the logical solution.

Situation : The Original Implementation derived colour and linewidth from KML ‘Styles’ and then plotted them through the matplotlib library.

Feature : Displaying Multiple KML Files on the Single Map

Solution : Add a .. loop to plot KML Files one by one.

Though quite simple in logic, it wasn’t so easy in implementation. The whole module had been hardcoded for a single KML file, and I had to make a lot of changes to achieve it.

(By this time, I received my First Evaluation, and the first pay :P)

Week 5 — High

I was very happy, motivated. I had completed my first month of coding, accomplished a major point. I used this momentum to work better!

Here are the following features I added!

Wednesday, July 1st :

  • Fixed the Bugs while loading multiple files
  • Added feature of selecting multiple files simultaneously in file selection dialog box
Selecting Multiple Files simultaneously

Thursday, July 2nd

  • Multiple Files can now be added simultaneously
  • Multiple Files can be displayed simultaneously
  • Functionality for Remove and Remove All Buttons for clearing the list
  • Double clicking on any KML file in the listWidget opens up a custom dialog box UI.
  • Finished Bug fixing

Friday, July 3rd

  • Single button “Add KML File” for adding & loading multiple KML Files simultaneously
  • Enhancement → duplicate files are not loaded again.
  • Reduced Size of ListWidget
  • Check- Uncheck feature to load KML layer
Check/ Uncheck KML File to display/ hide respective plot

Week 6 — Low

I started the week on a high, enthused with the smooth accomplishment of features everyday. My main task now was to add a customize functionality to each KML File. Each KML File could have their own color, linewidth, and could be easily added, removed, displayed and saved. One simple task.

I could not do it.

I tried on Monday, wasn’t able to do it. ‘Lets try tomorrow again”.
Tuesday, Wednesday passed. By Thursday, I was on edge; I wasn’t making any Journalheadway in the feature, I hadn’t updated my mentors.

Thursday night, I realized what I had to do. And it literally frightened me.

The problem was to store data (linewidth, colour) for each KML File, and keep updating it, with every change.

I had been using two different lists to store data. One list to run the files, another to run the patches for plotting. I realized, I had to change the data structure on which I had built the entire project.

Nested Dictionaries!

My plan is to create a structure like :
Dict = { ‘ file 1’ : {‘color’ : […. ], ‘linewidth’ : ‘ 3’},
‘file 2’ : {…………………………………………}}

I slept on it. Started working from Friday, day to night, replaced each and every part, transformed it all into a dictionary storing information about every file , patch , linewidth and colour. I worked all weekend on it. Sunday night, I was finally able to display individual colour and linewidth for each and every KML File.
I was so happy!! And the peaceful sleep that I had :))))

All the data is stored in nested dictionaries, which can easily find problems, if any. Here’s the result :

Feature to modify individual colour and linewidth

Week 7 — Drag

The ‘Merge KML’ feature involves merging several KML Files together, into a single file.

The Scenario where this is useful is : You used several files, u displayed them, u changed their colours and linewidths. Now you wish to save them. You do not want to do the whole process again. This is where merge KML comes in.

It creates a single file comprising of all the files. You simply need to load this file, and you will get all your plots back.

There is very less info on doing that on the internet. Most of the stuff I found was combining KML files i.e. joining Placemarks together etc. But that wouldn’t have been feasible for the large files that we use.

So I tried some experiments, and decided to copy the root elements of each file, add a Folder as a new root, and then put them all in a folder. It works!!

I tried it on all the sample files, and its working. There might be issues with other files, cos merging is a tricky business, but I think it should work for the majority :))

The only condition is that the KML File should not have any irrelevant stuff ( like comments ) between <kml> and the first tag : <Document> or <Folder> or whatever.

Do check it out :))

(This feature works, but its in its primary stage : it merges the KML Files, but shows them all with the same linewidth and colour. I propose to save the states as envisioned by the User.)

Week 8 — Turbulence

Writing Tests is tough. You have to have a different mindset; instead of defending your code, you attack it, trying to find its weaknesses. In the larger picture , this makes your code more stronger and durable.

Testing code often reveals that it cannot be tested.

I thought writing tests would be easy. From what I had seen, I had to simulate button clicks and then use assert statements.

But not all clicks, events are easy to simulate. I wasn’t able to simulate selecting a file from a QFileDialog, and it took me the whole week to find a workaround to select files.

And the mock library.. uff.

That is one of the advantages of test-driven development. If you think about the test first, you do not run into problems such as this later.You maybe see now, why it is a good idea to separate UI from logic, if you didn’t know that before.

Makes much more sense now.

This is how my Second Month ended :))

(Currently, I am progressing with my project in the third month of GSoC. I will write about the next part of my journey soon!Three-fourths in, lets do this!)

Thanks for reading!

--

--

Aryan Gupta

Individuality must prevail, if not Originality. (Twitter: @thodakaafi)